IDSA Assignment 2
IDSA Assignment 2
Department of
Artificial Intelligence and Data Science
Assignment No: 2
Title of Assignment: Write a program to take students’ marks as input and
perform various operations on them.
Objective: To learn about arrays and their uses, performing actions on arrays.
Materials Required:
Computer
IDE that is supported
Visual Studio Code
Procedure:
CODE:
#include<iostream>
using namespace std;
int result(int a[], int n){
int absent = 0, passed = 0, failed = 0;
for(int i = 0; i<n ; i++){
if(a[i]==999){
absent++;
}
else if(a[i]>=45 && a[i]<=100){
passed++;
}
else{
failed++;
}
}
cout<<"The Number of Passed students: "<<passed<<"\n";
cout<<"The Number of Failed students: "<<failed<<"\n";
cout<<"The Number of Absent students: "<<absent<<"\n";
return 0;
}
float average(int a[], int n){
float count = 0;
float sum = 0;
float avg;
for(int j = 0; j<n; j++){
if(a[j]!=999){
count++;
sum+=a[j];
}
}
avg = sum / count;
cout<<"The Average marks are "<< avg <<endl;
return 0;
}
int frequency(int a[], int n) {
int maxValue = 101;
int freqA[maxValue] = {0};
if (allAbsent) {
cout << "No marks other than absent (999) are present." << endl;
return 0;
}
int highestFreq = 0;
for (int k = 0; k < maxValue; ++k) {
if(freqA[k] > highestFreq) {
highestFreq = freqA[k];
}
}
Conclusion: In this experiment, we learnt about arrays, their functions and how to
iterate through them and how to perform mathematical operations on the arrays.
It helped us find the number of passed, failed, absent students, the average marks,
highest and lowest marks, the highest frequency marks in the class.