My Profile

I, Das ShrikKrishna J. MCA III IMSCD&R, Ahmednagar.

Monday, 15 August 2011

Implement Multiple Structures

Write a Program in C to Implement Multiple Structures
#include<stdio.h>
#include<conio.h>
struct student_personal
{
int roll;
char name[50];
int age;
};
struct student_academic
{
int maths;
int science;
int english;
int total;
};
void main()
{
struct student_personal ps;
struct student_academic as;
printf("Enter Roll Number\n");
scanf("%d",&ps.roll);
printf("\nEnter name\n");
scanf("%s",&ps.name);
printf("\nEnter age\n");
scanf("%d",&ps.age);
printf("\nEnter marks for Maths\n");
scanf("%d",&as.maths);
printf("\nEnter marks for Science\n");
scanf("%d",&as.science);
printf("\nEnter marks for English\n");
scanf("%d",&as.english);
as.total=(as.maths)+(as.science)+(as.english);
printf("\n\nRoll Number \t Name \t\t Age\n\n");
printf(" %d \t \t %s \t %d \n",ps.roll,ps.name,ps.age);
printf("\n\nMarks of Student %s\n\n",ps.name);
printf("Maths : %d\n",as.maths);
printf("Science : %d\n",as.science);
printf("English : %d\n",as.english);
printf(" ----\n");
printf("Total : %d\n",as.total);
getch();
}

No comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | cheap international calls