Thursday, February 10, 2011

STRUCTURES EXAMPLE PROGRAM IN C

 /*  
 */  
 #include<stdio.h>  
 struct student  
 {  
      char name[20];  
      char id[10];  
      char class[5];   
      float marks;   
 };   
 main( )  
 {  
   struct student std[10];   
   int i;   
   for(i=0;i<10;i++)  
        {  
             scanf("%s%s%s",std[i].name,std[i].id,std[i].class);  
             scanf("%f",&std[i].marks);  
        }  
  printf("Name\tId\tclass\tmarks\n");  
   for(i=0;i<10;i++)  
        {  
             printf("%s\t%s\t%s",std[i].name,std[i].id,std[i].class);  
             printf("\t%0.2f\n",std[i].marks);  
        }  
   printf("Students Details of More than 5 Marks:\n");  
   printf("Name\tId\tclass\tmarks\n");  
   for(i=0;i<10;i++)  
        {  
             if(std[i].marks>=5){  
             printf("%s\t%s\t%s",std[i].name,std[i].id,std[i].class);  
             printf("\t%0.2f\n",std[i].marks);}  
        }  
 }  

No comments:

Post a Comment