Array in Structures :
Sometimes, it is necessary to use structure members with array.
Program :
/* Program to demonstrate array in structures.
Creation Date : 23 Nov 2010 06:07:11 PM
Author : www.technoexam.com [Technowell, Sangli] */
#include <stdio.h>
#include <conio.h>
struct result
{
int rno, mrks[5];
char nm;
}res;
void main()
{
int i,total;
clrscr();
total = 0;
printf("\n\t Enter Roll Number : ");
scanf("%d",&res.rno);
printf("\n\t Enter Marks of 3 Subjects : ");
for(i=0;i<3;i++)
{
scanf("%d",&res.mrks[i]);
total = total + res.mrks[i];
}
printf("\n\n\t Roll Number : %d",res.rno);
printf("\n\n\t Marks are :");
for(i=0;i<3;i++)
{
printf(" %d",res.mrks[i]);
}
printf("\n\n\t Total is : %d",total);
getch();
}
Output :
Enter Roll Number : 1
Enter Marks of 3 Subjects : 63 66 68
Roll Number : 1
Marks are : 63 66 68
Total is : 197_
Kindly Bookmark this Post using your favorite Bookmarking service:
Related Posts: C programing tutorials,
structure and union
0 comments:
Post a Comment
Dont Forget for Commets