Computer Programming C Laboratory: Practical C Programs

Write a C program to print student grade using structure

C Program with Algorithm, Flowchart, Output

Simple C Program with Algorithm, Flowchart, Output - Computer Programming - C

Write a program to print student grade using structure.


AIM

To write a program to print student grade using structure.


ALGORITHM

Step‒1: Start

Step-2 : Define structure stud with the following members

        rollno integer

        name[30] character

        mark1,mark2, mark3, total: integer

        avg: float

        grade character

End stud

Step-3 : Read input n

Step-4 : Set a loop to get record details

Step-5 : Read a[i].rollno, a[i].name

Step-6 : a[i].mark1, a[i].mark2, a[i].mark3

Step-7 : a[i].total=a[i] + mark1+a[i].mark2+a[i].mark3

Step-8 : a[i].avg=a[i].total/3

Step-9 : [End of step‒4]

Step-10 : Check if a[i].avg <40 then assign a[i].grade = D

Step‒11 : Check if a[i].avg <60 then assign a[i].grade = C

Step‒12 : Check if a[i].avg< 80 then assign a[i].grade = B else

Step‒13 : a[i].grade='A'

Step‒14 : Print a[i].rollno, a[i].name, a[i].mark1, a[i].mark2,

a[i].mark3,a[i].total, a[i].avg, a[i].grade

Step‒15 : Stop


FLOWCHART



PROGRAM

#include<stdio.h>

#include<conio.h>

struct stud

{

int rollno;

char name[30];

int mark1,mark2,mark3,total;

float avg;

char grade;

}a[25];

void main()

{

int i,n;

printf("Enter the number of students :");

scanf("%d",&n);

for(i=0;i<n;i++)

{

      printf("Enter the student %d details :",i+1);

      printf("\nRollNo:");

      scanf("%d",a[i].rollno);

      printf("Name:");

      scanf("%s",a[i].name);

      printf("Mark 1: ");

      scanf("%d",&a[i].mark1);

      printf("Mark 2:");

      scanf("%d",&a[i].mark2);

      printf("Mark 3:");

      scanf("%d",&a[i].mark3);

      a[i].total=a[i].mark1+a[i].mark2+a[i].mark3;

      a[i].avg=a[i].total/3;

if(a[i].avg<40)

         a[i].grade = 'D';

else if (a[i].avg<60)

         a[i].grade='c';

else if (a[i].avg<80)

         a[i].grade='B';

else

         a[i].grade='a';

}

printf("\t\tStudents mark details: \n");

printf("\n Rollno\t Name \t\tmark 1\tmark 2\tmark3\ttotal\taverage");

for(i=0;i<n;i++)

         printf("\n%d\t%s\t\t%d\t%d\t%d\t%d%.2f\t%c",a[i].rollno,a[i].name, a[i].mark1,a[i].mark2,a[i].mark3,a[i].total,a[i].avg,a[i].grade);

}


OUTPUT

Enter the number of students :2

Enter the student 1 details :

RollNo:100

Name:Muni

Mark 1: 89

Mark: 2:80

Mark 3:76

Enter the student 2 details :

RollNo:101

Name:Mahi

Mark 1: 87

Mark: 2:90

Mark 3:67

Students mark details:

Rollno  Namemark1  mark2  mark3 total  average Grade

100 Muni 89 80 76 245 81.00 A

101 Mahi 87 90 67 244 81.00 A

 

Computer Programming C Laboratory: Practical C Programs : Tag: C Programming : C Program with Algorithm, Flowchart, Output - Write a C program to print student grade using structure


Computer Programming C Laboratory: Practical C Programs



Under Subject


Computer Programming C

CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming C Laboratory

CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation



Related Subjects


English Essentials I

EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


தமிழர் மரபு - Heritage of Tamils

UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Calculus

MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Physics I

PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Chemistry I

CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Makerspace

ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming C

CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming Python

CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Fundamentals of Electrical and Electronics Engineering

EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation


Introduction to Mechanical Engineering

ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation


Introduction to Civil Engineering

CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation


Essentials of Computing

CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation


Applied Physics I Laboratory

PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Applied Chemistry I Laboratory

CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Computer Programming C Laboratory

CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Computer Programming Python Laboratory

CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Engineering Drawing

ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electronics and Electrical Engineering

EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation


Essentials of Computing - Laboratory

CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation