Why scanf doesn't work in the c compiler provided in sololearn? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

Why scanf doesn't work in the c compiler provided in sololearn?

scanf command takes input values. https://code.sololearn.com/c69Fs7d2A26X/?ref=app

1st May 2018, 9:42 AM
Shubhodeep Paul
Shubhodeep Paul - avatar
5 Réponses
+ 4
#include <stdio.h> int main() { float a, b; printf("Enter 2 numbers to find their sum.\n"); scanf("%f %f",&a, &b); float sum=a+b; printf("Sum of a and b is %f.\n", sum); return 0; }
1st May 2018, 9:48 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
working you only forgot to put "&" ,infront of a,b scanf("%f %f",&a,&b);
1st May 2018, 9:48 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
It works ur code is wrong #include <stdio.h> int main() { float a, b; printf("Enter 2 numbers to find their sum.\n"); scanf("%f %f", &a, &b); float sum=a+b; printf("Sum of a and b is %f.\n", sum); return 0; }
1st May 2018, 9:48 AM
Yugabdh
Yugabdh - avatar
+ 1
This is corrected code enter two values in pop up and separate them by pressing enter
1st May 2018, 9:49 AM
Yugabdh
Yugabdh - avatar
+ 1
Thanks!! My mistake!!
1st May 2018, 9:52 AM
Shubhodeep Paul
Shubhodeep Paul - avatar