"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Tuesday, February 9, 2010

Write a program to enter names; marks of 5 subjects for individual students for a class ( assume class can hold max. 30 students). Now, calculate total marks and print names , total in columnar format. (use 1D or 2D array )


#include<iostream.h>
#include<conio.h>

void main()
{

char name[30] ;
int marks[50][50], tot [ 50];

for ( int i = 0; i < 30 ; i++)
{
cout << "\n Enter Name of the student ";
cin >> name [i];

tot[i] = 0;

cout<< "\n Enter marks for 5 subjects : ";
for (int j = 0; j < 5 ; j++)
cout<< "\n Sub " << j+1;
cin >> marks[i][j];
tot[i] = tot[i] + marks[i][j];
}
}
clrscr(); 
cout<<"\n\n Name \t\t Total \n\n";
for( i = 0; i<=18 ; i ++)
{
cout<< name[i]  <<"\t\t" << tot[i] <<  "\n" ;
}
cout<<"\n Press any key to continue..... ";
getch();

clrscr();
cout<<"\n\n Name \t\t Total \n\n";
for( i = 19; i< 30 ; i ++)
{
cout<< name[i]  <<"\t\t" << tot[i]  <<  "\n" ;
}
 getch();

}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.