+2 votes
in Class 12 by kratos

Will the following program ** successfully? If not, state the reason():

| (i) #include<stdio.h>void main() {int s1,s2,num;s1=s2=0;for(x=0;x<11;x++){cin<<num;if(num>0)s1+=num;else s2=/num;}cout<<s1<<s2;} | (i) #include<stdio.h>void main() {int x,sum=0;cin<<n;for(x=1;x<100;x+=2)if x%2==0sum+=x;cout<<"SUM=">>sum;} |

1 Answer

+1 vote
by kratos
 
Best answer

| (i) Will encounter a compile time error for following reasons: | (ii) Will encounter a compile time error for following reasons: |
| The variable ‘x’ is not declared.
With cin statement ‘<<’ symbol is used instead of ‘>>’.
Invalid semicolon at the end of if statement.
|
The variable ‘n’ is not declared.
There should be a parenthesis in if statement. ‘
>>’ is used with cout statement instead of ‘<<’.
|

...