Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working with integers from user input in C
#1
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().
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  User input and output with double in C Qomplainerz 0 423 07-26-2023, 06:03 PM
Last Post: Qomplainerz
  User input and short int conversion in C Qomplainerz 0 391 07-26-2023, 03:49 PM
Last Post: Qomplainerz
  Storing short integers in C Qomplainerz 0 393 07-26-2023, 03:45 PM
Last Post: Qomplainerz
  Working with floats from user input in C Qomplainerz 0 358 07-26-2023, 08:23 AM
Last Post: Qomplainerz
  Working with strings in C Qomplainerz 0 221 07-25-2023, 11:40 AM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 7 Guest(s)