Classwork_1.5: Write a C code that ask the user to enter the name of person, gender (male or female) and age and display these quantities. You need to create a structure to solve this problem.
Output: |
#include <stdio.h> struct Person { char name[100]; char gender[10]; int age; }; int main() { struct Person person; printf("Enter name: "); fgets(person.name, 100, stdin); printf("Enter gender: "); scanf("%s", person.gender); printf("Enter age: "); scanf("%d", &(person.age)); printf("\nName: %s", person.name); printf("Gender: %s\n", person.gender); printf("Age: %d\n", person.age); return 0; }
Get Answers For Free
Most questions answered within 1 hours.