GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Nov-2004, 10:27
justachessgame justachessgame is offline
New Member
 
Join Date: Oct 2004
Posts: 13
justachessgame is on a distinguished road

Help With float Arrays PLEASE!!!!!


I was wondering if anyone could help me with a program?

My instructions are to write the portion of a program that declares a float array with 100 elements. Write the code that performs the following operations:

1.) Displays the sum of the elements in the array.

2.) Displays the smallest number in the array.

3.) Displays the 5 largest numbers in the array.

Please, any help would be greatly appreciated!
  #2  
Old 04-Nov-2004, 10:35
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,648
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by justachessgame
I was wondering if anyone could help me with a program?

My instructions are to write the portion of a program that declares a float array with 100 elements. Write the code that performs the following operations:

1.) Displays the sum of the elements in the array.

2.) Displays the smallest number in the array.

3.) Displays the 5 largest numbers in the array.

Please, any help would be greatly appreciated!

OK. I'll start:

CPP / C++ / C Code:

#include <???>   /* probably stdio.h or iostream, depending on whether it's C or C++ */

int main()
{
  float x[100];

  /* you put some stuff here                                     */
  /* If you have any questions about your code or mine, just ask */
  
  return 0;
}

Regards,

Dave
  #3  
Old 04-Nov-2004, 11:45
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,108
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough
Quote:
Originally Posted by justachessgame
My instructions are to write the portion of a program that declares a float array with 100 elements. Write the code that performs the following operations:

Dave post shows you this part. The only question I have is you say you have to write the portion of the program. Does this mean you are working with a group that is writing the rest of the code. If so, it would be wise to determine what storage needs you already have in your assignment.
Quote:
Originally Posted by justachessgame
1.) Displays the sum of the elements in the array.
Code:
float array_sum = 0;
Quote:
Originally Posted by justachessgame
2.) Displays the smallest number in the array.
Code:
float smallest_number ; // Maybe set this to the smallest possible ??
Quote:
Originally Posted by justachessgame
3.) Displays the 5 largest numbers in the array.
Code:
float five_large[5] ; // Here you could set all to the largest possible ??

Now you know what variables that you need to create code for. I find it easy to define my goals and then work at them.
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
  #4  
Old 04-Nov-2004, 12:29
justachessgame justachessgame is offline
New Member
 
Join Date: Oct 2004
Posts: 13
justachessgame is on a distinguished road
Quote:
Originally Posted by cable_guy_67
Dave post shows you this part. The only question I have is you say you have to write the portion of the program. Does this mean you are working with a group that is writing the rest of the code. If so, it would be wise to determine what storage needs you already have in your assignment.

Code:
float array_sum = 0;

Code:
float smallest_number ; // Maybe set this to the smallest possible ??

Code:
float five_large[5] ; // Here you could set all to the largest possible ??

Now you know what variables that you need to create code for. I find it easy to define my goals and then work at them.

Thank you Kind Folks!! I will try the rest now that you have given me a starting point! If I have any questions...I will surely ask! Thank You!
 
 

Recent GIDBlogFlickr uploads of IA pictures by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ help Grid C++ Forum 7 25-Oct-2004 22:40
need help with passing 3 arrays into a function tommy69 C Programming Language 14 07-Apr-2004 00:22
Please Help, problems writing c program REVISED soulfly C Programming Language 6 03-Mar-2004 13:57

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:04.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.