Hi everyone. I am trying to do a simple program in C which reads two double numbers from the keyboard and displays the sum to the user. Even though the compiling is ok, the program doesn't run as expected. The code is:
Code:
#include <stdio.h>
int main (void)
{
double num1, num2, sum;
printf("Type in the first number: ");
scanf("%f", &num1);
printf("Type in the second number: ");
scanf("%f", &num2);
sum = num1 + num2;
printf("%f + %f = %f.", num1, num2, sum);
return 0;
}
What is wrong with this code?
Thanks in advance!