Programming in "C‟ | Write a program in „C‟ to define a structure „Person‟ with structure members as name and age. Accept this data for one person and display the same.

 #include<stdio.h>

struct Person

{

char name[20];

int age;

};

main()

{

struct Person p;

clrscr();

//accept data

printf("Enter name of the person:");

scanf("%s",p.name);

printf("Enter age of the person:");

scanf("%d",&p.age);

//Display data

printf("Name of the person : %s\n",p.name);

printf("Age of the person : %d",p.age);

getch();

Post a Comment

0 Comments