Friday, 5 February 2016

Best example of goto keyword

Program to Print whether the number is even or odd 

#include<stdio.h> 
main(){
int n;
printf(''Enter the number :");
scanf("%d",&n);
if(n%2= = 0){
goto even;
}
else{
goto odd;

}

even  : 
printf("Number is even");

goto end;

odd : 
printf("Number is odd ");
goto end;

end: 
printf("\n");

getch();
return 0;


}

No comments :

Post a Comment