after printf program ends itself without doing the rest of code ? C -
after printf line program ends didnt why.
#include<stdio.h> int main () { int sum,multiply,divide,difference,num1,num2; char i; scanf("%d", &s1); scanf("%d", &s2); printf("type initial of operation : "); scanf("%c", &i); return 0 ; }
there no way compile that, since s1
, s2
undefined variables.
thus, information happened when ran moot, since there no way run it.
you meant:
if(scanf("%d %d", &num1, &num2) == 2) { printf("operands %d , %d, type initial of desired operation:\n"); if(scanf("%c", &i) == 1) { } }
it's important check scanf()
has succeeded before relying on return value.
Comments
Post a Comment