Thursday, March 12, 2009

Structure Lesson 1

#include
#include
void main(void)
{
clrscr();

Declaring structure

struct person
{
char name[80];
int age;
int mobileNo;
};

Defining its object

struct person prs;

printf("Enter your name: ");

gets(prs.name);

printf("Enter your age: ");

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

printf("Enter your mobileNo: ");

scanf("%d",&prs.mobileNo);

printf("Name = %s \n Age = %d \n MobileNo = %d",prs.name,prs.age,prs.mobileNo);

getch();
}

No comments:

Post a Comment