student record using pointer and structures

3
STUDENT RECORD USING POINTER AND STRUCTURES PROGRAM: #include<stdio.h> #include<conio.h> void main() { struct student { char name[25]; char regno[25]; int avg; char grade; } stud[50],*pt; int i,no; printf(“Enter the number of the students…”); scanf(“%d”,&no); for(i=0;i<no;i++) { printf(“\n student[%d]information:\n”,i+1); printf(“Enter the name”); scanf(“%s”,stud[i].name); printf(“\nEnter the roll no of the student”); scanf(“%s”,stud[i].regno); printf(“\nEnter the average value of the student”); scanf(”%d”,&stud[i].avg); } pt=stud; for(pt=stud;pt<stud+no;pt++) {

Upload: rathnampm

Post on 07-Apr-2015

117 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Student Record Using Pointer and Structures

STUDENT RECORD USING POINTER AND STRUCTURES

PROGRAM:

#include<stdio.h>#include<conio.h>void main(){struct student {char name[25];char regno[25];int avg;char grade;}stud[50],*pt;int i,no;printf(“Enter the number of the students…”);scanf(“%d”,&no);for(i=0;i<no;i++){printf(“\n student[%d]information:\n”,i+1);printf(“Enter the name”);scanf(“%s”,stud[i].name);printf(“\nEnter the roll no of the student”);scanf(“%s”,stud[i].regno);printf(“\nEnter the average value of the student”);scanf(”%d”,&stud[i].avg);}pt=stud;for(pt=stud;pt<stud+no;pt++){ if(pt->avg<30)pt->grade=’D’;elseif(pt->avg<50)pt->grade=’C’;elseif(pt->avg<70)pt-.grade=’B’;else

Page 2: Student Record Using Pointer and Structures

pt->grade=’A’;}print(“\n”);print(“NAME REGISTER-NO AVERAGE GRADE\n”);for(pt=stud;pt<stud+no;pt++){printf(“%-20s%-10s”,pt->name,pt-regno);printf(:%10d\t %c\n”n,pt->avg,pt->grade);} getch();}

OUTPUT:

Enter the number of the students3student[1]information:Enter the name MUNIEnter the roll no of the student 100Enter the average value of the student 95Student[2]information:Enter the name LAKEnter the roll no of the student 200Enter the average value of the student 55Student[3] information:Enter the name RAJAEnter the roll no the student 300Enter the average value of the student 25NAME REGISTER-NO AVERAGE GRADEMUNI 100 95 A LKA 200 55 B RAJA 300 25 D

Page 3: Student Record Using Pointer and Structures