Write program that reads some information of 10 students (name [max 15] , level number , #of points , #of hours , GPA , student id ). These fields should be filled for each student by user except GPA. The GPA (max: 5) should be calculate it by function that takes #of points , #of hours as arguments and return the value of GPA.
Using small menu, the user can done some operations:
1. print all information for specific name
2. print all students names and ids that their GPA more than 4
3. sort the students information using student name
4. exit


here is the code

#include<iostream.h>
#include<string.h>
float fun(float arr[][1],float arr[][3]){

	arr[i][5]=(arr[i][1]/arr[i][2]);
	return arr[i][5];}
int main(){
	char ch,temp;
	int i,b,a,num;
	char arr_name[10];
	float arr[10][5];
	cout<<"this is a small menu to show what this program do\n";
	cout<<"to use this program you should use the same order of \n";
	cout<<"the menu......\n";
	cout<<"                *^*^*^*****^*^*^*\n";
	do{
	cout<<"1. print all information for specific name.\n";
	cout<<"2. prints all student's names and id's that their GPA more than 4.\n";
	cout<<"3. sort the student information using the student's name.\n";
	cout<<"4. exit.\n";
	cin>>num;

	switch(num){
	case 1 :for(i=0;i<10;i++){

		cout<<"enter the name for student "<<i<<endl;
		gets(arr_name[ch]);
		cout<<"enter the student's level number: ";
			cin>>arr[i][0];
			cout<<"enter the student;s points of all classes: ";
			cin>>arr[i][1];
			cout<<"enter the students hours of all classes: ";
			cin>>arr[i][2];
			cout<<"enter the student's id number: ";
			cin>>arr[i][3];
			arr[i][5]=fun(arr[][1],arr[][2]);
			cout<<"the GPA for student number "<<i<<" is "<<arr[i][5]<<endl;
		}
		break;
	case 2 :for(i=0;i<10;i++){
		if(arr[i][5]>4)
			cout<<"the student's name is :  "<<arr_name[i]<<"    id number:  "<<arr[i][4]<<"\n";
			}
		break;
		case 3 :for(i=0;i<10;i++){
		for(a=0;a<10;a++){
			for(b=9;b<=a;b--){
				if (arr_name[b-1]>arr_name[b]){
					temp=arr_name[b-1];
					arr_name[b-1]=arr_name[b];
					arr_name[b]=temp;}
			}
		}
			cout<<arr_name[i];
			}
		break;
	case 4 :cout<<"thank you for visiting this program\n";
		break;
	}while(num!=4);
	return 0;
	}
}

<< moderator edit: added [code][/code] tags -- start doing this yourself >>

float fun(float arr[][1],float arr[][3]){

	arr[i][5]=(arr[i][1]/arr[i][2]);
	return arr[i][5];}

Which is who?

Proper formatting such as indenting and whitespace can also make it a whole lot easier to read your own code to find mistakes.

>what is the problem
What are the symptoms? I can point out a lot of stuff that could be considered a "problem", but since we can't read your mind, we don't know which of them you're referring to.

Dave also asked you a question and suggested a way to improve your chances of finding the problem on your own. You post here often, and I can't help but notice that your formatting style is inconsistent and doesn't promote readability.

>>Dave also asked you a question and suggested a way to improve your chances of finding the problem on your own

sorry Dave but I did not Know what you mean because the english is not my native language

>>You post here often

is this buther you ??
I post here cause I do not have any one to teach me but if you notice that I always try and post my trying also

any way thanks dave,narue

your sis
some one

>is this buther you ??
Not at all. I like activity on my forums. However, if you wrote code so that it's easier to read and easier to debug, you would be able to solve most of your problems. Making code work is a more important skill that writing code from scratch, because you do it more often. If you're always asking for help then you're not building that skill as you should be.

>sorry Dave but I did not Know what you mean
He meant that you have two arrays, both called arr. That won't work, and since we don't know which array goes where in your expression, we can't help you fix it.

And you still haven't told us the problem that you're having. You just said you have a problem, posted the program requirements, and a bunch of code that's hard to read.

>but the problam was that the code did not work
*sigh*

You seem to have trouble with this concept. "It doesn't work" is about as helpful as just posting your code with no explanation at all. There are degrees of "not working". Does it compile? Do you get errors? When it runs, does it crash? If not, how far does it get before doing something other than you expected? What did you expect? What did it do that differs from that?

Nobody likes debugging, and nobody is going to help you unless you make it as easy as possible to solve your problem.

This article has been dead for over six months. Start a new discussion instead.