Welcome to Westonci.ca, your ultimate destination for finding answers to a wide range of questions from experts. Get quick and reliable answers to your questions from a dedicated community of professionals on our platform. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.

Write and test a program that accepts the user’s name (as text) and age (as a number) as input.

The program should output a sentence containing the user’s name and age.


Sagot :

name = input("Enter your name: ")

age = int(input("Enter your age: "))

print("Your name is",name,"and you are",age,"year(s) old.")

I wrote my code in python 3.8. I hope this helps.

Program description:

  • Defining header file.
  • Defining the main method.
  • In the next step,  the character array as "name" and an integer variable "age" is declared that uses the input method to the input value.
  • After input value, a print method is declared that prints value with the message.

Program:

#include <stdio.h>//header file

int main()//defining main method

{

   char name[50];//defining character array as name

   int age;//defining integer variable

   printf("Enter name: ");//print message

   scanf("%s",name);//input name

   printf("Enter age: ");//print message

   scanf("%d",&age);//input age

   printf("Hi.. \%s",name); //print value with message

   printf(" your age is %d.",age);//print value with message

   return 0;

}

Output:

Please find the attached file.

Learn more:

brainly.com/question/13160158

View image codiepienagoya
Visit us again for up-to-date and reliable answers. We're always ready to assist you with your informational needs. We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.