Write A Program To Read The Marks of 10 Students in 5 Subjects Calculate The Average and Assign Grades. Now Draw Its Graph Matrix and Find Its V (G)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

LAB-8

Write a program to read the marks of 10 students in 5 subjects


calculate the average and
assign grades. Now draw its graph matrix and find its V(G).

code
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct student
{
char sname[10];
float marks[5];
float total,avg;
char grade;
}s[10];
void main()
{
clrscr(); 1
int i;
for(i=1;i<10;i++) 2
{
cout<<"\n Enter the name of the student"<<i<<"\t"; 3
gets(s[i].sname); 4
for(int j=0;j<5;j++) 5
{
cout<<"\n Enter the marks in subject"<<j<<"\t"; 6
cin>>s[i].marks[j]; 7
}
for(j=0;j<5;j++) 8
{
s[i].total=s[i].total+s[i].marks[j]; 9
}
s[i].avg=s[i].total/5; 10
cout<<"\n The average of student"<<i<<"is:"<<s[i].avg; 11
if(s[i].avg>90.0) 12
s[i].grade='O'; 13
else if((s[i].avg<90.0)&&(s[i].avg>=85.0)) 14
s[i].grade='A'; 15
else if((s[i].avg<85.0)&&(s[i].avg>=80.0)) 16
s[i].grade='B'; 17
else if((s[i].avg<80.0)&&(s[i].avg>=70.0)) 18
s[i].grade='C'; 19
else 20
s[i].grade='D'; 21
cout<<"\n The grade of student" <<i<<"\t"<<s[i].grade; 22
}
getch(); 23
}

The cyclomatic complexity is V(G) = 5. That means there are five indepent path in
the flow graph.

Output
Enter the name of student 0: A
Enter the marks in subject1 99
Enter the marks in subject2 98
Enter the marks in subject3 97
Enter the marks in subject4 96
Enter the marks in subject5 95
The average of student 0 is : 97
The grade of student 00 enter the name of student1
The average of student 0 is : 97
The grade of student 00 enter the name of student1 B
Enter the marks in subject0 88
Enter the marks in subject1 85
Enter the marks in subject2 86
Enter the marks in subject3 87
Enter the marks in subject4 84
The average of student 1 is : 86
The grade of student1A enter the name of the student2

Graph matrix:

You might also like