switch (default)
Apr 19, 2011 at 9:30am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#include <stdio.h>
#include <conio.h>
int main()
{
int a,b;
int c;
printf(" ilk sayıyı giriniz ; \n " );
scanf("%d" ,&a);
printf(" ikinci sayiyi giriniz ; \n " );
scanf("%d" ,&b);
printf(" Bir işlemci giriniz ( 1 2 3 4 ) ; \n " );
scanf("%d" ,&c);
switch (c)
{
case '1' :
printf(" %d " ,(a+b));
break ;
case '2' :
printf(" %d " ,(a-b));
break ;
case '3' :
printf(" %d " ,(a*b));
break ;
case '4' :
printf(" %d " ,(a/b));
break ;
default :
printf("bilinmeyen işlemci sectiniz" );
}
getch ();
return 0;
}
hi. :) I am a C user. i get 'bilinmeyen işlemci sectiniz' message when i enterred ' 1 '. why don't i see case (1) in screen? Can you help me? I am sorry for my English ;)
thank you. :)
Apr 19, 2011 at 9:34am UTC
Because '1' != (int) 1. '1' -> is ASCII value 48
So omit the ''
Apr 19, 2011 at 10:34am UTC
coder777
Ah, okay. thank you. ;)
Topic archived. No new replies allowed.