+ 1

Help to understand code in c languags

I am learning basics of c language, in this part 4 name formatting is difficult to understanding for me. When i run programme there is no output show. My code is here #include <stdio.h> int main() { int x; float num; char text[20]; scanf("%d %f %s", &x, &num, text); }

17th Jan 2020, 6:38 AM
Jitendra Kumar
Jitendra Kumar - avatar
9 Réponses
+ 4
No output because you are just declaring variables and read them you are not printing them. Use: printf("%d %f %s", x, num, text); But I recomend that you input one at the time so split your scanf in three.
17th Jan 2020, 6:52 AM
Mihai Apostol
Mihai Apostol - avatar
+ 2
Coder Kitten In my opinion to have control over each input. Otherwise each input should be separated by spaces(prone to errors).
17th Jan 2020, 11:37 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Input for example 42 1.1 jitendra separated by space https://code.sololearn.com/c9809CTesHcH/?ref=app
17th Jan 2020, 5:25 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Jeevan Chandra Joshi You forgot return 0; Just for consistency.
18th Jan 2020, 6:32 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
In this code you haven't use any function to print something in output screen. Here you have use the scanf function which is used to read input from user.If you add a single followed by the scanf statement then it will print which it reads from user. printf("%d %f %s", x, num, text);
19th Jan 2020, 4:51 AM
Abhinav Shukla
Abhinav Shukla - avatar
0
I don't understand
17th Jan 2020, 4:19 PM
Jitendra Kumar
Jitendra Kumar - avatar
0
//This code will produce your output #include <stdio.h> int main() { int x; float num; char text[20]; scanf("%d %f %s", &x, &num, text); printf("%d %f %s", x, num, text); return 0; }
18th Jan 2020, 6:23 AM
Jeevan Chandra Joshi
Jeevan Chandra Joshi - avatar
0
#include <studio.h> Int main(){ Int x; float text[20]; Scanf("%d %f %s", &x, &num, text); Printf ( %d %f %s", x, num, text); return 0; }
18th Jan 2020, 8:27 AM
AJISAFE Odunayo
0
Thanks to all
29th Mar 2020, 5:18 PM
Jitendra Kumar
Jitendra Kumar - avatar