if content
#include <stdio.h>
#include <stdlib.h>
int main()
{
int no,ans;
printf("enter a number");
scanf("%d",&no);
ans=no%2;
if(ans==0)
printf("%d is an even number",no);
else
printf("%d is an odd number",no);
return 0;
}
write the above programe using switch
#include <stdio.h>
#include <stdlib.h>
int main()
{
int no,ans;
printf("enter a number");
scanf("%d",&no);
ans=no%2;
switch(ans)
{
case 0:printf("%d is an even",no);break;
case 1:printf("%d is an odd",no);break;
}
}
No comments:
Post a Comment
please wait...