QP School
Working with integers from user input in C - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: C 18 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=32)
+--- Thread: Working with integers from user input in C (/showthread.php?tid=5141)



Working with integers from user input in C - Qomplainerz - 07-26-2023

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().