Answer to Question #10412 in C++ for hamee
write a program in modular programming asking for an array of 6 students gpa in ascending order
1
2012-06-07T08:04:29-0400
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
int arrayiofgpa[100];
void sort(int ar[], int size)
{
int temp;
for(int i = 0; i < size; i++)
for(int j = 0; j < size - i - 1; j++)
if(ar[j] > ar[j + 1])
{
temp = ar[j];
ar[j] = ar[j + 1];
ar[j + 1] = temp;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
for(int i=0;i<6;i++){
cout<<"Enter gpa for student "<<(i+1)<<": ";
cin>>arrayiofgpa[i];
}
sort(arrayiofgpa,6);
cout<<"GPF in ascending order is: ";
for(int i=0;i<6;i++){
cout<<arrayiofgpa[i]<<" ";
}
getch();
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment