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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -