473,387 Members | 1,791 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,387 software developers and data experts.

Arrays Question

can someone explain to me what is the meaning of the right braket here
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.     int a[5],y,max;
  6.  
  7.     for (i=0;y<5;i++)
  8.     {
  9.         cin>>a[i];
  10.         if (y==0) max=a[y];
  11.         if (a[y]>max) max=a[];
  12.     }
  13.     cout<<"max numb is:"<<max;
  14.     system("pause");
  15.     return 0;
  16. }
May 29 '12 #1
6 1623
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

Which right bracket? You have a few of them.

On a side note, the code is all jacked up, it won't run correctly.
May 29 '12 #2
I know,i fixed it and now i understand the thing with [] they are arrays. What i am tryin to do is a program that it will say the maximum number of a given list.if you can help me i would be very thankfully.
May 29 '12 #3
Rabbit
12,516 Expert Mod 8TB
1) You never instantiate your i variable.
2) You never initilize your y variable.
3) You don't need both, just one of them. Pick one and use it.
4) On line 11, you need to specify the index you want to return.
May 29 '12 #4
change y to i everywhere
line11: change->: max=a[i];
hope it works fine :)
May 29 '12 #5
Ok,so now i need the same program but with loop not arrays,not with anything,only loop.can anyone help me please.
oh and btw i have done that with arrays look
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.     int a[5],y,max;
  6.     cout<<"Enter 5 numbers "<<endl;
  7.     for (y=0;y<5;y++)
  8.     {
  9.         cin>>a[y];
  10.         if (y==0) max=a[y];
  11.         if (a[y]>max) max=a[y];
  12.     }
  13.     cout<<"The maximum value of the numbers you have entered is : "<<max<<endl;
  14.     system("pause");
  15.     return 0;
  16. }
  17.  
May 30 '12 #6
that's it i have done it it's finished and done!! hurray!
Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.      int input;
  6.      int highest = 0;
  7.      int lowest = 0;
  8.  
  9.     cout<< "Enter A  Number (0 to stop the loop): \n";
  10.      cin >> input;
  11.      highest = input;
  12.      lowest = input;
  13.      while(input!=0)
  14.      {
  15.         cout << "Enter another number (0 to stop the loop): \n";
  16.         cin >> input;
  17.         if(input >= highest)
  18.           highest = input;
  19.         else if(input<= lowest)
  20.           lowest = input;
  21.      }
  22.    cout<< "Maximum number is:" << highest<<endl;
  23.  system("pause");
  24.  
  25. }
  26.  
May 30 '12 #7

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

Similar topics

7
by: csx | last post by:
Hi everyone! two quick questions relating to arrays. Q1, Is it possible to re-assign array elements? int array = {{2,4}, {4,5}}; array = {2,3}
3
by: Meo | last post by:
Hi, Here is what I'm doing in python 2.4.1 : >>> aOfa=]*3]*4 >>> aOfa , , ], , , ], , , ], , , ]] >>> aOfa.append(1) >>> aOfa , , ], , , ], , , ], , , ]]
2
by: Mike | last post by:
I am wanting to create an array that will hold a series of SQL statements that will be built in a function called on the OnLoad event. I need this array to be visible at a later stage in the module...
3
by: James dean | last post by:
I have created algorithms in C# unsafe code and have fixed the arrays in memory for optimum performance. I use multidimensional arrays rather than jagged arrays. The algorithms i use usually read a...
5
by: Diarmuid | last post by:
Are there control arrays in vb.net 2005? Maybe some one could help me out with an example. I know how to this in VB6. My database is called Planner.mdb There is a table called Weekdays. I want to...
3
by: John Gregory | last post by:
I'm new to perl and have a question. The perl book says that hashes map keys to values. Using the reverse function you can map values to keys. My problem is I have a hash of arrays and I want...
12
by: lifeshortlivitup | last post by:
I am trying to construct two, one-dimensional parallel arrays that will give me a letter grade for whatever score I enter. The two arrays I need are minimum score and grade. I don't understand how...
2
by: hamiltongreg | last post by:
I am pretty new to Java and have a question about where to begin with my program. The assignment is to Modify the Inventory Program so the application can handle multiple items. Use an array to...
9
by: fr0zen | last post by:
alright, well ive been having a problem trying to get this code to work, i have my three arrays char first; char second; char third; First i have to use the fgets() function to get a...
3
by: jimgym1989 | last post by:
we have a question on our exam a couple of days ago..it is True or False. This is the question intlist = new int; the statement list = list + list; updates the content of the fifth...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.