Register    Login    Forum    Search    FAQ

Board index » Programming » C/C++




 Page 1 of 1 [ 6 posts ] 



Author Message
 Post subject: Need help with assignment
 Post Posted: Sat Jul 24, 2010 2:05 am 
Offline
n00b
n00b

Joined: Tue Jul 20, 2010 11:37 am
Posts: 4
Automation electronics
john 85 79
Sam 71 85
Clinton 50 65
Harry 89 77
Tom 74 69

When 1 is pressed it displays the name and scores of the students in descending order for electronics.
When 2 is pressed it displays the name and scores of the students in descending order for Automation.
when 3 is pressed it displays the average scores of the students for both subject in descending order.


Last edited by datalogger on Fri Jul 30, 2010 10:27 pm, edited 2 times in total.

Top 
 Post subject: Re: Need help with assignment
 Post Posted: Tue Jul 27, 2010 5:02 am 
Offline
n00b
n00b

Joined: Tue May 25, 2010 6:50 pm
Posts: 7
You can have an array of strings, and an array of numbers, then something like:

for (int c=0; c<5; c++)
cout << names[c] << ": " << scores[c] << endl;

You will get more (and better) answers if you show that you have put in effort. Also, exploring on your own is the only way you can ever learn and enjoy programming.

you would have code above that (most likely a bubble sort, and something to keep the array of strings in sync with the scores), but I don't want to do the question for you (I don't want to inhibit learning and encourage plagiarism). If you post some code, I'll gladly help you improve it.


Top 
 Post subject: Re: Need help with assignment
 Post Posted: Fri Jul 30, 2010 12:48 pm 
Offline
n00b
n00b

Joined: Tue Jul 20, 2010 11:37 am
Posts: 4
danmmcd wrote:
You can have an array of strings, and an array of numbers, then something like:

for (int c=0; c<5; c++)
cout << names[c] << ": " << scores[c] << endl;

You will get more (and better) answers if you show that you have put in effort. Also, exploring on your own is the only way you can ever learn and enjoy programming.

you would have code above that (most likely a bubble sort, and something to keep the array of strings in sync with the scores), but I don't want to do the question for you (I don't want to inhibit learning and encourage plagiarism). If you post some code, I'll gladly help you improve it.


thanks! i will post my work soon


Top 
 Post subject: Re: Need help with assignment
 Post Posted: Fri Jul 30, 2010 10:33 pm 
Offline
n00b
n00b

Joined: Tue Jul 20, 2010 11:37 am
Posts: 4
Code:
#include <stdio.h>
void main()
{
   char name[5],[10]; john,Sam,Clinton,Harry row, column;
   unsigned int Automation, 79,85,65,77,69,row, column;
   unsigned int Electronics, 85,71,50,89,74,row,  column;
        int choice 1,choice 2,choice3
   double avg 1 = 0; avg 2 = 0;
   for(count=0; count<5; count=count+1)
   {
      printf(Choice 1:"name and mark for electronic\n");
      scanf("%s %d %d", name, &mark1, &mark2);
      total = total + mark1 + mark2;

      printf(Choice 2:"name and mark for automation\n");
      scanf("%s %d %d", name, &mark1, &mark2);
      total = total + mark1 + mark2;

      printf(Choice 3:"Average Scores for students\n");
      scanf("%s %d %d", name, &mark1, &mark2);
      total = total + mark1 + mark2;
      total 1 =  mark1;
      total 2 =  mark2;
   }
   
}


please Advice on my work and correct my mistakes as i started programming few weeks ago and this is my first assignment. Thanks i cant seem to fix the errors


Top 
 Post subject: Re: Need help with assignment
 Post Posted: Sat Jul 31, 2010 10:22 pm 
Offline
Chuck Norris Status
Chuck Norris Status
User avatar

Joined: Mon May 17, 2010 3:52 am
Posts: 1125
Location: Munich
idk if you are in a class but, if you already deal with 2d arrays in your class, then you must have noticed the errors in these lines:

char name[5],[10]; john,Sam,Clinton,Harry row, column;
unsigned int Automation, 79,85,65,77,69,row, column;
unsigned int Electronics, 85,71,50,89,74,row, column;
int choice 1,choice 2,choice3
double avg 1 = 0; avg 2 = 0;

so you should go back a little bit and learn the basics before you deal with 2d arrays and strings and pointers and stuff, its all for nothing if you dont know the basics and the syntax


Top 
 Post subject: Re: Need help with assignment
 Post Posted: Tue Aug 03, 2010 12:50 pm 
Offline
Tutorial Writer

Joined: Sun May 16, 2010 1:44 pm
Posts: 756
Location: The C++ Forum
I second that statement.

_________________
Image


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 6 posts ] 




Board index » Programming » C/C++


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: