Skip to main content

DSL

2. Problem Statement:
Write C/C++ program to store marks scored for first test of subject 'Data Structures and Algorithms' for N students. Compute
I. The average score of class
ii. Highest score and lowest score of class
iii. Marks scored by most of the students
iv. list of students who were absent for the test

Program Code: (Implementation)
#include <iostream>
using namespace std;
class Test
{
    int dsa[30],i,j,n,sum,cnt[50],k,rn[30]; //data members
    float av;
public:
    Test()  //default constructor
    {
        i=j=n=0;
        av=sum=k=0;
    }
    void getdata(); //member functions
    void show();
    void avg();
    void Ab_stud();
    void HS_LS();
    void MS_score();
}; //end of class declaration

//Function name: getdata()
//return type: void
//Parameter :Nil
// To accept information of test.

void Test::getdata()
{
    cout<<"\nHow many student in SE Comp Div: A : ";
    cin>>n;
    cout<<"\n\t-----------------------------------------------------";
    cout<<"\n\tEnter the marks scored for first test of subject DSA: ";
    cout<<"\n\t-----------------------------------------------------";
    cout<<"\n\nStudent who remains Absent for the test please enter -1 for them:";
    cout<<"\n                     -------------------------------------         ";
    for(i=0;i<n;i++)
    {
     cout<<"\nEnter the marks of Roll no: "<<i+1<<" : ";
     cin>>dsa[i];
    }
}

void Test::MS_score()
{
    for(i=0;i<50;i++)
    {
        cnt[i]=0;
    }
    for(i=0;i<50;i++)
    {
        for(j=0;j<n;j++)
        {
            if(dsa[j]==i)
            {
                cnt[i]=cnt[i]+1;
            }
        }
    }
    /*cout<<"\n\nCount of marks..\n\n";
    for(i=0;i<50;i++)
    {
        cout<<"\t"<<cnt[i];
    }*/
    cout<<"\n\n Marks Scored by most of the student in test are: \n";
    
    k=0;
    j=0;
        int max=cnt[j];
    for(i=0;i<50;i++)
    {
     if(cnt[i]>=max)
     {
         max=cnt[i];
         k=i;
     }
    }
    cout<<"\n\nMAximum marks "<<k<<" scored by "<<max <<" Students...\n";
    for(i=0;i<n;i++)
    {
        if(dsa[i]==k)
        {
            rn[j]=i;
            j++;
        }
    }
    cout<<"\n\n Students Roll Number are as follows..\n\n";
    for(i=0;i<j;i++)
    {
        cout<<"\t"<<rn[i]+1;
    }
}

void Test::show()
{
    cout<<"\n\nFirst Test Marks of Subject DSA are as follows...\n";
    cout<<"\n*********************************\n";
    cout<<"|  Roll No\t"<<"|"<<" DSA Marks     |";
    cout<<"\n*********************************\n";
    for(i=0;i<n;i++)
    {
        cout<<"|\t"<<i+1<<"\t|\t"<<dsa[i]<<"\t|\n";
    }
    cout<<"---------------------------------\n";
}

void Test::avg()
{
    int p=0;
    cout<<"\nAverage Score of Class = > ";
    for(i=0;i<n;i++)
    {
        if(dsa[i]!=-1)
        {
            sum=sum+dsa[i];
            p++;
        }

    }
    av=sum/p;
    cout<<av;
}

void Test::Ab_stud()
{
    int cnt=0;
    cout<<"\n\nTotal Number of Student Absent for DSA Test\n";
    cout<<"\nRoll No\t Marks\n";
    for(i=0;i<n;i++)
    {
        if(dsa[i]==-1)
        {
            cout<<i+1<<"\tAbsent\n";
            cnt++;
        }
    }
    cout<<"\n\tTotal_Absent_Student :=: "<<cnt;
}

void Test::HS_LS()
{
    int min=0;
    int max=0,rno=0,i=0;
    cout<<"\n\nHighest Score of the Class for DSA Subject are as follows..\n";
    max=dsa[i];
    for(i=0;i<n;i++)
    {
        if(dsa[i]==-1)
        {

        }
        else if(dsa[i]>=max)
        {
            max=dsa[i];
            rno=i;
        }
    }
    cout<<"\n\tDSA Highest Score: "<<"Roll No : "<<rno+1<<" Marks : "<<max;
    cout<<"\n\nLowest Score of the Class for DSA Subject are as follows..\n";
    rno=0;
    min=dsa[j];
    for(j=0;j<n;j++)
    {
        if(dsa[j]==-1)
        {

        }
        else if(dsa[j]<=min)
        {
         min=dsa[j];
         rno=j;
        }
    }
    cout<<"\n\tDSA Lowest Score: "<<"Roll No : "<<rno+1<<" Marks : "<<min;
}

int main()
{
    Test T;
    T.getdata();
    T.show();
    T.avg();
    T.Ab_stud();
    T.HS_LS();
    T.MS_score();
    cout << "\n\n\n!!!Good Bye!!!" << endl; // prints !!!Hello World!!!
    return 0;
}

Comments

Popular posts from this blog

DSL

9: Program Setatement A palindrome is a string of character that‘s the same forward and backward. Typically, punctuation, capitalization, and spaces are ignored. For example, ‖Poor Dan is in a droop‖ is a palindrome, as can be seen by examining the characters ―poor danisina droop‖ and observing that they are the same forward and backward. One way to check for a palindrome is to reverse the characters in the string and then compare with them the original-in a palindrome, the sequence will be identical. Write C++ program with functions- 1. to check whether given string is palindrome or not that uses a stack to determine whether a string is a palindrome. 2. to remove spaces and punctuation in string, convert all the Characters to lowercase, and then call above Palindrome checking function to check for a palindrome 3. to print string in reverse order using stack Program: #include<iostream> #include<string.h> #define MAX 100 using namespace std;  struct stack ...

DSL

4: Problem Statement: Write C/C++ program for storing matrix. Write functions for  a) Check whether given matrix is upper triangular or not  b) Compute summation of diagonal elements  c) Compute transpose of matrix  d) Add, subtract and multiply two matrices #include<iostream> #include<cstdio> void Upper_Triangular(int a[10][10],int n,int m) { for(int i=0;i<n;i++){ printf("\n"); for(int j=0;j<m;j++) if(i>=j) printf(" %d ",a[i][j]); else printf(" %d ",0); } } void Addition(int a[10][10],int b[10][10],int m,int n) { int c[10][10],i,j; for(i=0;i<m;++i) { for(j=0;j<n;++j) { c[i][j]=0; c[i][j]+=a[i][j]+b[i][j]; } } printf("\nAddition Of two Matrix is : \n"); for(i=0;i<m;++i) { for(j=0;j<n;++j) { printf(" %d ",c[i][j]); } printf("\n"); } } void Dif...

OOP

6.Problem statement Develop an object oriented program in C++ to create a database of student  information system containing the following information: Name, Roll number, Class, division, Date of Birth, Blood group, Contact address, telephone number, driving license no. etc Construct the database with suitable member functions for initializing and destroying the data viz constructor, default constructor, Copy constructor, destructor, static member functions, friend class, this pointer, inline code and dynamic memory allocation operators-new and delete. Program #include<iostream> #include<stdio.h> #include<cstring> using namespace std; class personal; static int count; class person {       char *name;       int *rollno,*classno;       char *bloodgroup,*div;                   public:person()              {     ...