- program
statements are executed from top to bottom.
Example:
sum=number1+number2;
average=sum/2;
Console.WriteLine("Sum="+sum);
Console.WriteLine("Average="+average);
2. Decision
Control Structures
- allows selection of
specific sections of code to be executed.
1. Simple
int score=30;
if(score<75){
Console.WriteLine("Failed");
}
else{
Console.WriteLine("Passed");
}
2. Nested
int score=30;
if(score<75){
Console.WriteLine("Failed");
}
else if
(score<85){
Console.WriteLine("Average");
}
else if
(score<90){
Console.WriteLine("Above
Average");
}
else{
Console.WriteLine("Excellent")
}
3. Complex
if(score<75){
if(….){}else{…}
else if (score<85){
if(….){}else{…}
}
else if (score<90){
if(….){}else{…}
}
else{
if(….){}else{…}
}
- 2
types of decision control structures
1. Sequential
if
2. Nested
if
3. Repetition
Control Structures
- allows the repetition of
an action while some condition remains true.
o do..while
loop
example1
do{
Console.Write("Try
Again[y/n]?: ");
tryAgain=char.Parse(Console.ReadLine());
}while(tryAgain=='y');
example2
do{
ctr++;
}while (ctr<=10);
o while
loop
example1
char tryAgain='y';
while(tryAgain=='y'){
Console.Write("Try
Again[y/n]?: ");
tryAgain=char.Parse(Console.ReadLine());
}
example2
int ctr=0;
while(ctr<=10){
ctr++;
}
o for
loop
for (int ndx = 0; ndx < 10; ndx++) {
Console.WriteLine
(ndx);
}
- 2
types of repetition control structures
1. Sentinel
loop
2. Counting
loop
For data science training in bangalore,
ReplyDeleteVisit:
Data Science training in bangalore
For Blockchain training in bangalore, Visit:
ReplyDeleteBlockchain training in bangalore
For Devops Training in Bangalore
ReplyDeleteMmorpg oyunlar
ReplyDeleteİnstagram Takipçi Satın Al
tiktok jeton hilesi
tiktok jeton hilesi
antalya saç ekimi
İNSTAGRAM TAKİPÇİ SATIN AL
Instagram Takipçi
METİN2 PVP SERVERLER
instagram takipçi satın al