1:
#include <stdio.h>
///*** compound statement:
int main()
{
int a;
if(5>10){
scanf("%d",&a);
printf("%d",5-a);
}
else
printf("(The first condition is wrong)\n");
return 0;
}
output: The first condition is wrong
2:
#include <stdio.h>
///The program will print odd number:
int main()
{
int a,b;
for(b=1;b<=5;b++){
a=(2*b-1);
printf(" %d ",a);
if(a>=9)
break;
}
return 0;
}
output: 1 3 5 7 9
3:
#include <stdio.h>
///The program will print even number:
int main()
{
int a,b;
for(b=1;b<=5;b++){
a=(2*b-1)+1;
printf(" %d ",a);
if(a>=10)
break;
}
return 0;
}
output: 2 4 6 8 10
No comments:
Post a Comment