Sunday, June 10, 2012

CS 110 COMPUTER PROGRAMMING LAB - Basic C Programs


//Program to Allot Students.

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

class student
{
private:
char name[20];
int rollno;
float marks[5];

public:
void getdata();
void allot();
void putdata();
};

void student::getdata()
{
cout<<"\n Enter Student's Name:\t";
gets(name);
cout<<"\n\n Enter Rollno:\t";
cin>>rollno;
cout<<"\n Enter Student's Marks (in 100):\t";
for(int i=0;i<5;i++)
{
cout<<"\n\n Enter the Mark of Subject"<<i+1<<":\t";
cin>>marks[i];
}
}
void student::putdata()
{
cout<<" \n\n The Allotment Profile is:";
cout<<"\n Name:\t";
puts(name);
cout<<"\n\n Rollno:\t"<<rollno;

for(int i=0;i<5;i++)
{
cout<<"\n\n Mark of Subject"<<i+1<<":";
cout<<marks[i];
}
}

void student::allot()
{
int sum=0;
int percent;
for(int i=0;i<5;i++)
sum+=marks[i];
percent=(sum/5);

if(percent>=96)
cout<<"\n\n Alloted to Computer Stream.";
if((percent>=91)&&(percent<=95))
cout<<"\n\n Alloted to Electronics Stream.";

if((percent>=86)&&(percent<=90))
cout<<"\n\n Alloted to Mechanical Stream.";

if((percent>=81)&&(percent<=85))
cout<<"\n\n Alloted to Electrical Stream.";

if((percent>=76)&&(percent<=80))
cout<<"\n\n Alloted to Chemical Stream.";

if((percent>=71)&&(percent<=75))
cout<<"\n\n Alloted to Civil Stream.";

if(percent<=71)
cout<<"\n\n You are Disqualified.";
}

void main()
{
clrscr();
student std;
std.getdata();
std.putdata();
std.allot();
getch();
}

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More