I'm new to C programming and whenever I try to run a code with the scanf it doesn't execute.
#include <stdio.h>
int main()
{
int a,b,s;
printf("Enter the first no: \n");
scanf("%d",&a);
printf("Enter the second number: \n");
scanf("%d",&b);
s=a+b;
printf("%d",s);
}
I get this output:
[Running] cd "c:\msys64\mingw32\bin\" && gcc Prog1.c -o Prog1 && "c:\msys64\mingw32\bin\"Prog1
and this upon termination:
[Done] exited with code=1 in 6.586 seconds
The exact same code works without scanf.
#include <stdio.h>
int main()
{
int a=3,b=5,s;
printf("Enter first no: \n");
printf("Enter the second no: \n");
s=a+b;
printf("%d",s);
}
Output:
Enter first no:
Enter the second no:
8
This is what happens on executing in cmd prompt:
[1]: https://i.stack.imgur.com/o08a9.jpg