Sunday, 11 December 2011

Write a program to print the details of a student in c

#include
#include
struct student
{
int rollno;
char name[20];
};
struct personal
{
int age;
char phone[10];
struct student s1;
};
void main()
{
struct personal p1;
clrscr();
printf("Enter roll number and name of the student:\n");
scanf("%d%s",&p1.s1.rollno,p1.s1.name);
printf("\nEnter age and phone number of the student :\n");
scanf("%d%s",&p1.age,p1.phone);
printf("\nThe roll number of the student is:%d",p1.s1.rollno);
printf("\nThe name of the student is:%s",p1.s1.name);
printf("\nThe age of the student is: %d",p1.age);
printf("\nThe phone number of the student is:%s\n",p1.phone);
getch();
}


OUTPUT
Enter roll number and name of the student:
23 RAM KUMAR VARMA

Enter age and phone number of the student:
20 277458

The roll number of the student is: 23

The name of the student is: mahesh

The age of the student is: 20

The phone number of the student is: 277458

No comments:

Post a Comment