Saturday, 6 October 2012

use of while, for and switch togather


#include<stdio.h>
void main()
{
int a;
printf("Enter your favorate number:");
scanf("%d",&a);


if(a==2){
int i=0;
while(i<5){
printf("the number is %d\n",i);
i++;

}
}

else if(a==4){

for(int i=0; i<4;i++){
printf("the number is %d\n",i);

}

}

else{
int c;
printf("Enter the number again");
scanf("%d",&c);
switch(c){
case 1:
printf("the number is odd and is 1");
break;
case 3:
printf("the number is odd and is 3");
break;

default:
printf("the number is unknown to the user");
break;

}

}
}


output will be ...........





No comments:

Post a Comment