Home
User Guide
DB Recovery
Download
Documents
FAQ
Books
About Me
C Programs
Stats

/* Program# 44
   date : 28-12-2008
   Arithmetic operator - using switch
*/

#include <stdio.h>
main(){
char a;
printf("\nEnter a operator :");
scanf("%c",&a);
switch(a){
case '+':
case '-':
case '*':
case '/':
printf("\nArithmetic operator %c",a);
break;
default:
printf("\n Not an arithmetic operator ");
}
}


output:
To compile the program, run the gcc command,
$ gcc p44.c  
Now the executable file is stored as a.out, to run
the program,

$ ./a.out
Enter a operator :&

 Not an arithmetic operator
$ ./a.out
Enter a operator :-

Arithmetic operator -
$ 






Powered by
Open Source Programmers