Summary
In this lab, you have learned how to read user input in C using the scanf()
function. You created a program that prompts users for their name and age, reads the input, and displays a personalized greeting message. This exercise has introduced you to basic input/output operations in C, working with different data types (char
arrays for strings and int
for integers), and the process of compiling and running a C program.
Key takeaways:
- The
scanf()
function is used to read input from the user.
- Different format specifiers (
%s
for strings, %d
for integers) are used depending on the type of input you're reading.
- When reading integers or other non-string types with
scanf()
, you need to use the &
operator to pass the address of the variable.
- The compilation process turns your C code into an executable program.
These fundamental skills form the basis for more complex C programming tasks and will be valuable as you continue to learn and develop your programming abilities. Remember, practice is key in programming - try modifying this program or creating new ones to reinforce what you've learned!