To input the name and age of the user and print both with a gap of one line in between
Answers
Answered by
0
Program:
C/C++
// C/C++ program to take input from the user
// and print the user's name and age to the
// console/output.
#include <stdio.h>
int main()
{
// Declare the required variables.
char *name; // Name of the user
int age; // Age of the user
// Require the user to input the values
puts("Your first name:");
scanf("%s", name);
puts("\nYour age:");
scanf("%d", &age);
// Print the user's name and age.
printf("\nName: %s\n Age: %d\n", name, age);
return 0;
}
Python
# Python program to take input from the user
# and print the name and age.
# Ask the user to input the required values.
name = input("Your name: ")
age = int(input("Your age: "))
# Print the name and age to the console
print("\nName:", name, "\n", "Age:", age)
Similar questions