473,395 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help Me Basic C++ Using Array LOWEST + HIGHEST = SUM

In C++ using arrays.

I need to create a C Program that will ask for five integers input from the user, then store these in an array. Then I need to find the lowest and highest integers inside that array and add them together. The output will be the result in this format: LOWEST+HIGHEST=SUM

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. void main (){
  3. int r[4], low, hig, ans, index;
  4. for(index=0, index<4, index++){
  5. printf("Enter number");
  6. scanf("%d",&x[index]);
  7. }
  8. for(index=0, index<4, index++){
  9. if(x[0]<x[index]){
  10. low=x[0];
  11. }
  12. for(inde=0, index<4, index++){
  13. if(x[1]<x[index]){
  14. low=x[1];
  15. }
  16. for(index=0,index=<4,index++){
  17. if(x[2]<x[index]){
  18. low=x[2];
  19. }
  20. for(index=0,index<4,index++){
  21. if(x[3]<x[index]){
  22. low=x[3];
  23. }
  24. for(index=0,index<4,index++){
  25. if(x[4]<[index]){
  26. low=x[4];
  27. }
  28. for(index=0,index>4,index++){
  29. if(x[0].>x[index]){
  30. hig=x[0];
  31. }
  32. for(index=0,index>4,index++){
  33. if(x[1],>x[index]){
  34. hig=x[1];
  35. }
  36. for(index=0,index>4,index++){
  37. if(x[2],>x[index]){
  38. hig=[2];
  39. }
  40. for(index=0,index>4,index++){
  41. if(x[3],>x[index]){
  42. hig=[3];
  43. }
  44. for(index=0,index>4,index++){
  45. if(x[4],>x[index]){
  46. hig=[4];
  47. }
  48. }
  49. ans=low+hig;
  50. printf("%d+%d=%d",low,hig,ans);
  51. getch();
  52. }
  53.  
Can you help me?
Oct 13 '08 #1
5 3771
gpraghuram
1,275 Expert 1GB
After getting the inputs sort the elemnts in the array and then take the first element(lowest) and the last element(highest) element.

Raghu
Oct 13 '08 #2
theirs anybody have a code!!!!!!!!!!!!!!!!!!!!1
that can detect minimum no. and maximum no.
when i input 10 7 2 15 5 with array????????????????????
Oct 13 '08 #3
donbock
2,426 Expert 2GB
It sounds like all you want to do is find the minimum and maximum values in an array. If that is the case, then sorting the array is overkill. You can make one pass through the array to conditionally update the min and max values.
Oct 13 '08 #4
sicarie
4,677 Expert Mod 4TB
ryuch311i-

Please check your PMs, accessible through the PMs link under the Network tab at the top of the page.

Thanks,

sicarie
Oct 13 '08 #5
First, if you want to input 5 integers then name the array r[5] not r[4].
And you changed the array name to x when it was declared r.

To find the lowest number in an array you should do this:

Spoonfeeding code removed

That's all you have to do.
And to find the highest number use the same concept.
Oct 13 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Michael Warner | last post by:
hey guys, I am having a bit of an issue with a project I'm doing. Basically what it will ultimately end up able to do is that it will accept set up a dynamic array based on user input and allow...
2
by: Kavitha Rao | last post by:
Hi, I am getting the following errors while trying to run this snippet in Microsoft Visual C++.Can't seem to print the crc value stored. /* +++Date last modified: 05-Jul-1997 */ /* Crc - 32...
20
by: honeygrl33 | last post by:
i accidentially erased something someone helped me write and i am soooo in trouble if i dont fix this, i really need the help!!!!! heres what i have: /* */ #include <stdio.h> #include...
21
by: Jaspreet | last post by:
I was working on some database application and had this small task of getting the second highes marks in a class. I was able to do that using subqueries. Just thinking what is a good way of...
1
by: thebrainmore | last post by:
could someone help with my average and sort functions in this program #include <iostream.h> //funtion prototypes int FindLowNum(int , int ); int FindHighNum(int , int);
1
by: po3gurl | last post by:
Hello to all is there anyone who could help me figure out why my program will not compile. This is my assignment but I have also included my work and I am getting a error that says (C1083) ...
7
by: BQuin | last post by:
Enter into array, 8 marks, then Call 3 functions greatest Smallest Average Each of these 3 functions will receive as parameters the array of marks as well as the # of elements in the array....
3
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i have an int array and was just wondering if there is a way to get the highest value in the array? for instance, int myValues = new int { 0, 1, 2 } highest value is 2. thanks,
3
by: Dameon99 | last post by:
Hi.. Im experiencing a weird error I dont know how to fix. I have a scanner object and whenever I use nextInt, anything above 3 causes the program to crash saying and links me to this line of the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.