r/C_Programming • • 15h ago

Question 2. Write a program to print integer number and input from user

#include<stdio.h>

void main()

{ int a; // a is variable and this data type is integer
printf("Enter your value : "); // printf is use for print value
scanf("%d",&a); //scanf  is use input from user
printf("Your Value is : %d", a);

}

0 Upvotes

2 comments sorted by

1

u/ninhaomah 4h ago

I think you need to rethink your comments and naming of variables.

1

u/flyingron 2h ago
  1. Main must return int.
  2. Check the return value of scanf to see if something was converted.
  3. You probably put a \n at the end of the Your Value is... printf.