what is the problem

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2005
Posts: 129
Reputation: some one is an unknown quantity at this point 
Solved Threads: 0
some one some one is offline Offline
Junior Poster

what is the problem

 
0
  #1
Apr 9th, 2005
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
  1. #include<iostream.h>
  2. #include<string.h>
  3. float fun(float arr[][1],float arr[][3]){
  4.  
  5. arr[i][5]=(arr[i][1]/arr[i][2]);
  6. return arr[i][5];}
  7. int main(){
  8. char ch,temp;
  9. int i,b,a,num;
  10. char arr_name[10];
  11. float arr[10][5];
  12. cout<<"this is a small menu to show what this program do\n";
  13. cout<<"to use this program you should use the same order of \n";
  14. cout<<"the menu......\n";
  15. cout<<" *^*^*^*****^*^*^*\n";
  16. do{
  17. cout<<"1. print all information for specific name.\n";
  18. cout<<"2. prints all student's names and id's that their GPA more than 4.\n";
  19. cout<<"3. sort the student information using the student's name.\n";
  20. cout<<"4. exit.\n";
  21. cin>>num;
  22.  
  23. switch(num){
  24. case 1 :for(i=0;i<10;i++){
  25.  
  26. cout<<"enter the name for student "<<i<<endl;
  27. gets(arr_name[ch]);
  28. cout<<"enter the student's level number: ";
  29. cin>>arr[i][0];
  30. cout<<"enter the student;s points of all classes: ";
  31. cin>>arr[i][1];
  32. cout<<"enter the students hours of all classes: ";
  33. cin>>arr[i][2];
  34. cout<<"enter the student's id number: ";
  35. cin>>arr[i][3];
  36. arr[i][5]=fun(arr[][1],arr[][2]);
  37. cout<<"the GPA for student number "<<i<<" is "<<arr[i][5]<<endl;
  38. }
  39. break;
  40. case 2 :for(i=0;i<10;i++){
  41. if(arr[i][5]>4)
  42. cout<<"the student's name is : "<<arr_name[i]<<" id number: "<<arr[i][4]<<"\n";
  43. }
  44. break;
  45. case 3 :for(i=0;i<10;i++){
  46. for(a=0;a<10;a++){
  47. for(b=9;b<=a;b--){
  48. if (arr_name[b-1]>arr_name[b]){
  49. temp=arr_name[b-1];
  50. arr_name[b-1]=arr_name[b];
  51. arr_name[b]=temp;}
  52. }
  53. }
  54. cout<<arr_name[i];
  55. }
  56. break;
  57. case 4 :cout<<"thank you for visiting this program\n";
  58. break;
  59. }while(num!=4);
  60. return 0;
  61. }
  62. }
<< moderator edit: added [code][/code] tags -- start doing this yourself >>
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: what is the problem

 
0
  #2
Apr 9th, 2005
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.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 129
Reputation: some one is an unknown quantity at this point 
Solved Threads: 0
some one some one is offline Offline
Junior Poster

Re: what is the problem

 
0
  #3
Apr 9th, 2005
please some one help me with this code
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,667
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 725
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: what is the problem

 
0
  #4
Apr 9th, 2005
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 129
Reputation: some one is an unknown quantity at this point 
Solved Threads: 0
some one some one is offline Offline
Junior Poster

Re: what is the problem

 
0
  #5
Apr 10th, 2005
>>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
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,667
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 725
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: what is the problem

 
0
  #6
Apr 10th, 2005
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 129
Reputation: some one is an unknown quantity at this point 
Solved Threads: 0
some one some one is offline Offline
Junior Poster

Re: what is the problem

 
0
  #7
Apr 10th, 2005
okay thanks but the problam was that the code did not work
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,667
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 725
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: what is the problem

 
0
  #8
Apr 10th, 2005
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC