Explain the switch statement and for loop control structure with syntax...
Answers
Answered by
3
switch statement is a selection statement which executes statements only in the matching case only.
syntax
cin>>operator;
switch(operator){
case '+':
cout<<a+b;
break;
case 'n':
statement 1;
statement n;
break;
default:
statement;
notice that break and switch are optional.
for loop is an iteration statement which repeats a statement until the loop condition fails or become false.
for(intialization;condition;assignment)
statement;
example for(int i=0;i<5;i++)
sum=sum+i;
for(;;) is also legal which is called infinite loop.
Shifapathan:
thank you!
Answered by
4
Attachments:
Similar questions