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().
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos