// newplusplus.cpp : Defines the entry point for the console application.
//share with your friends if u found any errors please comments thanks :) :)
#include "stdafx.h"
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int flag=0;
void sortedoutput(int [], int&);
void input1(int d1[],int &a)
{
for(int i=0; i<a; i++)
{
cout<<"ENTER THE MARKS OF STUDENT"<<i+1<<":";
cin>>d1[i];
}// for end
}// input 1 end
void output(int d2[],int &b)
{
cout<<"__________output_____________"<<endl;
for(int j=0; j<b; j++)
{
cout<<"THE INPUT MARKS OF STUDENT "<<j+1<<":";
cout<<d2[j]<<endl;
}
}
void sorting(int ds[],int &num)
{
cout<<"_________sorting function_________"<<endl;
int hold;
for(int z=0; z<num; z++)
{
for(int m=0; m<num-1; m++)
{
if(ds[m]>ds[m+1])
{
hold=ds[m];
ds[m]=ds[m+1];
ds[m+1]=hold;
} // if end
}// nested for end
} // for end
sortedoutput(ds,num);
}
void sortedoutput(int so[], int&n)
{
cout<<"_____sorted output____"<<endl;
for(int i=0; i<n; i++)
{
cout<<so[i]<<endl;
}
}
int main()
{
system("cls");
int data1[200]; // class A array
int data2[200]; //class B array
int a1,a2;
cout<<" welcome to the sorting array values in two classes"<<endl;
do{
int ch;
cout<<"\t\t********MENU***********"<<endl;
cout<<"\t\t1) input class A student"<<endl;
cout<<"\t\t2) input class B student"<<endl;
cout<<"\t\tt3)show the student in class A"<<endl;
cout<<"\t\tt4)show the student in class B"<<endl;
cout<<"\t\t5)sort the student in class A"<<endl;
cout<<"\t\t6)sort the student in class B"<<endl;
cout<<"enter the choice"<<endl;
cin>>ch;
switch(ch)
{
case 1:
cout<<"HOW MANY STUDENT IN YOUR CLASS A"<<endl;
cin>>a1;
input1(data1,a1);
flag=1;
break;
case 2:
cout<<"how many student in class b"<<endl;
cin>>a2;
input1(data2,a2);
break;
case 3:
if(flag==1)
output(data1,a1);
else
cout<<"ENTER the input first in class A"<<endl;
break;
case 4:
if(flag==1)
output(data2,a2);
else
cout<<"Enter the input first class B"<<endl;
break;
case 5:
sorting(data1,a1);
break;
case 6:
sorting(data2,a2);
default:
cout<<"input wrong"<<endl;
}// switch end
}while(1); // do while main end
system("pause");
return 0;
}