C Program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

C Program

when I run this program it gives no output, why?? #include <stdio.h> int main() { int a = 6; int b = 4; int c = 2; int result; result = a - b + c; // 4 result = a + b / c; // 8 result = (a + b) / c; // 5 return 0; }

29th Sep 2018, 3:37 AM
Lakshman Patel
Lakshman Patel - avatar
7 Answers
+ 5
Hi! You need a function to generate the outputs: example "printf". #include <stdio.h> int main() { int a = 6; int b = 4; int c = 2; int result; result = a - b + c; // 4 printf("The first result is %d\n",result); //here result = a + b / c; // 8 printf("The second result is %d\n",result); //here result = (a + b) / c; // 5 printf("The third result is %d",result); //here return 0; }
29th Sep 2018, 3:47 AM
Nimrod A. Holguín L.
Nimrod A. Holguín L. - avatar
+ 3
No problem! 👍 You're welcome!
29th Sep 2018, 3:58 AM
Nimrod A. Holguín L.
Nimrod A. Holguín L. - avatar
+ 3
Because you haven't included printf function if you add printf ("%d",result); then it will show you output
27th Mar 2020, 4:07 PM
Suraiya Jahan
Suraiya Jahan - avatar
+ 2
ohh thanks i did really silly mistake
29th Sep 2018, 3:55 AM
Lakshman Patel
Lakshman Patel - avatar
+ 1
No print... lol Keep learning!!!
30th Sep 2018, 10:55 AM
ShortCode
0
where is your "printf ()"? you have to use it.
29th Sep 2018, 6:58 AM
Anin Hasan
Anin Hasan - avatar
0
There is no print statementLakshman Patel
5th Aug 2020, 9:14 AM
P. Aamir
P. Aamir - avatar