| | |
what is the problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2005
Posts: 129
Reputation:
Solved Threads: 0
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
<< moderator edit: added [code][/code] tags -- start doing this yourself >>
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
C++ Syntax (Toggle Plain Text)
#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; } }
float fun(float arr[][1],float arr[][3]){ arr[i][5]=(arr[i][1]/arr[i][2]); return arr[i][5];}
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
>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.
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.
•
•
Join Date: Apr 2005
Posts: 129
Reputation:
Solved Threads: 0
>>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
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.
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.
>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.
*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.
![]() |
Similar Threads
- Problem with Windows Update and WinXP (Web Browsers)
- Installing Windows 98 On VMware. Floppy problem (Windows 95 / 98 / Me)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Problem with T720 (Cellphones, PDAs and Handheld Devices)
- Connection Problems (Networking Hardware Configuration)
- Encoding (Unicode) problem in IE 6.0 (Web Browsers)
- .htaccess mod_rewrite problem (Linux Servers and Apache)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
Other Threads in the C++ Forum
- Previous Thread: help me in this home work please
- Next Thread: Unexpected output when program exucuted
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






