My Code:
#include <iostream>
using namespace std;
int main(){
int a[500];
int value;
for(int i=0;i<500;i++){
cout<<"Please Enter a value (0-100):";
cin>>value;
if (value>=0 && value<=100){
a[i]=value;
}
else if(value<0){
break;
}
}
for(int i=0;i<5;i++){
cout<<a[i]<<" ";
}
}
Output Sample:
Please Enter a value (0-100):10
Please Enter a value (0-100):12
Please Enter a value (0-100):5
Please Enter a value (0-100):-5
10 12 5 0 786432
--------------------------------
Process exited after 7.597 seconds with return value 0
Press any key to continue . . .
Array has values that is not given. I have no idea how they are defined. Please help me about this.
Note: Sorry for my mistakes. I am still a newbie.
Aucun commentaire:
Enregistrer un commentaire