- 2

Write a program that displays an integer then increments the integer by 3.

22nd Jun 2021, 5:47 PM
Winny Weke
Winny Weke - avatar
4 odpowiedzi
+ 3
#include <stdio.h> int main(){ int c; printf("Enter value of c: \n"); scanf("%d", &c); c += 3; printf("%d", c); return 0; }
22nd Jun 2021, 6:12 PM
Winny Weke
Winny Weke - avatar
+ 3
Your code is working fine but if you have to give the output in a test case then you have to follow the question of how do they want to print the output. For example: Sample input: 3 Sample output: 6 then if you print the line Enter value of c: it won't work because the machine doesn't understand english.
22nd Jun 2021, 6:17 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
Seems to be your homework anyways post what you have tried
22nd Jun 2021, 5:55 PM
Atul [Inactive]
0
If I only wrote the scanf bit without the printf bit above it and someone else tried to run it, they wouldn't know when to enter the value of c so, yeah...
22nd Jun 2021, 6:42 PM
Winny Weke
Winny Weke - avatar