C Program to Input User Name and Age and Display Output-Beginner’s Guide

How It Works:
1.We.start by including <stdio.h>, which gives us the tools to display messages and read input.
2.Inside the main() function, we create two variables: name, a place to store the user’s name, and age, to store their age.
3.We ask the user to type their name with printf(), and then we grab what they type with scanf().
Note: this method reads only until the first space, so it’s good for simple names.
4.Next, we ask for their age, and again use scanf() to save it into the age variable.
5.Finally, we print out the name and age using printf(), so the user can see what they entered.

What Will You See When You Run It?
Here’s an example of what the program’s output might look like:

Enter your name: Sankalan
Enter your age: 30
Your name is: Sankalan
Your age is: 30


Conclusion:
Though this program is simple, it an essential step toward learning how to write programs that will be able to interact with the user. This would be at an introductory level toward writing much more complicated programs such as applications and games. Moreover, it is fun to watch the program react to the information the user provides!



Java Topics wise FAQ   SQL Topics wise FAQ


Other C Programs

1.Write a program in C to find area of circle using single-line comments.
2.Write a C program to find addition of two numbers with multi-line comments to write down the purpose of every steps.
3.Write a program in C that describe a complex mathematical formula with nested comments.
4.Write a C program to demonstrate the declaration and initialization of variables of different data types.
5.write a program code in c to swap a values of the two variable without using a third variable.
6.Write a program in c to find area of rectangle by accepting variable value length and width.
7.Write a program that accepts user input for employee name and salary, and then display them using those variables.
8.Write a program in C to demonstrate and decide the size of int, float, char, and double data types.
9.Write a program in C to convert temperature from Celsius to Fahrenheit using proper data types.
11.Write a program in C that accepts any two numbers from user and calculate addition, multiplication, subtraction and division (+, *,-, /) and show the result.
13.Write a program in C that asks the user to enter the marks obtained in three subjects. Read the marks using scan. Calculate the average marks and display the student details.

Other Topic:-->>Dynamic memory FAQ. || Operators Assignments in C.