07-26-2023, 08:19 AM
Example:
int age;
printf("Enter your age: ");
scanf("%d", &age);
printf("Your age is: %d\n", age);
Explanation:
In this example, we declare an int variable age to store the user's age.
We prompt the user to enter their age using printf().
We use the %d format specifier in scanf() to read an integer value from the user and store it in the age variable.
Finally, we print the user's age using printf().
int age;
printf("Enter your age: ");
scanf("%d", &age);
printf("Your age is: %d\n", age);
Explanation:
In this example, we declare an int variable age to store the user's age.
We prompt the user to enter their age using printf().
We use the %d format specifier in scanf() to read an integer value from the user and store it in the age variable.
Finally, we print the user's age using printf().