Wednesday, 5 December 2012

CPL PROGRAM 14b CODING

                         ARRAY OF STRUCTURES                                           
CODING:                                                  
                                                                                                                 
#include<stdio.h>
#include<conio.h>
struct student
{
 int rollno;
 char name[10],grade;
 float percent;
}a[10];
void main()
{
 int i,n;
 clrscr();
 printf("\n Enter the No.of students");
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  printf("Enter students information.....");
  printf("\n Enter Student Roll NO : ");
  scanf("%d",&a[i].rollno);
  printf("\n Enter the Student Name : ");
  scanf("%s",&a[i].name);
  printf("\n Enter the percentage : ");
  scanf("%f",&a[i].percent);
  printf("\n Enter the student grade : ");
  scanf("%c",&a[i].grade);
 }
 for(i=0;i<=n;i++)
 {
  printf("\n Roll no :%d",a[i].rollno);
  printf("\n Name    :%s",a[i].name);
  printf("\n Percent :%f",a[i].percent);
  printf("\n Grade   :%c",a[i].grade);
 }
 getch();
}

No comments:

Post a Comment