Example Programs for Control Flow Statements
//Find out sum of two numbers is even or odd main() { int n1,n2,sum; printf("value for n1"); scanf("%d",&n1); printf("value for n2"); scanf("%d",&n2); sum=n1+n2; if(sum%2==0) printf("\n%d is even",sum); else printf("\n %d is odd",sum); } //Accept a character and check whether it is vowel or not main() { char c1; printf("Enter a character"); scanf("%c",&c1); switch(c1) { case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': printf("\n%c is vowel",c1); break; default:printf("\n%c is not vowel",c1); break; } } // display the numbers between 1 and 10 main() { int n; for(n=1;n<=10;n++) printf("%d ",n); } // display the numbers between 1 and 10 usi...
Comments
Post a Comment