Friday, August 19, 2011

Program to demonstrate the use of Structure in C Language.

//Program to demonstrate the use of Structure in C Language.
#include<stdio.h>
#include<conio.h>
void main()
{
 struct student
 {
   int subject1;
   int subject2;
   int subject3;
 };
 int i,n,total;
 float av;
 clrscr();
 struct student st[20];
 printf(" \n enter the number of student:");
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
   printf("\n Enter marks of three subjects of %dth student:",i+1);
   total=0;
   scanf("%d%d%d",&st[i].subject1,&st[i].subject2,&st[i].subject3);
   total=st[i].subject1+st[i].subject2+st[i].subject3;
   printf("\n total matrks of %dth student is =%d",i+1,total);
   av=(float)total/3;
   printf("\n Average marks of %dth student is=%f",i+1,av);
 }
 getch();
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More