so something very funny is going on right now.at least to me.
when i input a value,it should display:
1)the value you just entered in the array
2)the value in index 0
3)the value in index 50
4)the sum of the number in index 50 and the number 23
the problems:
1)on the first input of 20,it should display the value i just entered which is 20.but it displayed 0 instead.but inputs after the first will display the value which i just entered.
why is that?
2)this "value for the first index in the array",should just display the first value which i entered at the start,which can be found stored inside index 0.but as i kept inputting values,the first index in the array would keep adding 1 to itself.when it should just kept displaying the first value inputted.
why is that?
#include <iostream>
#include <cstdlib>
#include <cstdio>
usingnamespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
//
int timmy[] = {} ;
int bob;
int counter = 0;
for(;;)
{
cout<<"input numbers-";
cin>>bob;
timmy[counter] = bob;
cout<<endl;
cout<<"value in the array = "<<timmy[counter];
cout<<endl;
cout<<"value for the first index in the array = "<<timmy[0];
cout<<endl;
++counter;
cout<<"value inside index 50 = "<<timmy[50];
cout<<endl;
cout<<"value in index 50 plus 23 = "<<timmy[50]+23;
cout<<endl;
}
}
Inside your for loop there is no way out. No way to end the for loop. Consider adding something like this:
1 2 3
std::cin >> bob;
if (bob == 0) break;
Your variable names may mean something to you but in the future choose better names that would be more understandable and more descriptive to others and yourself. This also makes you program easier to understand when you look at it six months from now.