can someone explain to me what is the meaning of the right braket here - #include <iostream>
-
using namespace std;
-
int main ()
-
{
-
int a[5],y,max;
-
-
for (i=0;y<5;i++)
-
{
-
cin>>a[i];
-
if (y==0) max=a[y];
-
if (a[y]>max) max=a[];
-
}
-
cout<<"max numb is:"<<max;
-
system("pause");
-
return 0;
-
}
6 1623
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.
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.
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.
change y to i everywhere
line11: change->: max=a[i];
hope it works fine :)
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 - #include <iostream>
-
using namespace std;
-
int main ()
-
{
-
int a[5],y,max;
-
cout<<"Enter 5 numbers "<<endl;
-
for (y=0;y<5;y++)
-
{
-
cin>>a[y];
-
if (y==0) max=a[y];
-
if (a[y]>max) max=a[y];
-
}
-
cout<<"The maximum value of the numbers you have entered is : "<<max<<endl;
-
system("pause");
-
return 0;
-
}
-
that's it i have done it it's finished and done!! hurray! - #include<iostream>
-
using namespace std;
-
int main()
-
{
-
int input;
-
int highest = 0;
-
int lowest = 0;
-
-
cout<< "Enter A Number (0 to stop the loop): \n";
-
cin >> input;
-
highest = input;
-
lowest = input;
-
while(input!=0)
-
{
-
cout << "Enter another number (0 to stop the loop): \n";
-
cin >> input;
-
if(input >= highest)
-
highest = input;
-
else if(input<= lowest)
-
lowest = input;
-
}
-
cout<< "Maximum number is:" << highest<<endl;
-
system("pause");
-
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics
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}
|
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
, , ], , , ], , , ], , , ]]
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |