0

Why my code is executing for infinite times?

#include <iostream> using namespace std; //reverse number using aaray int main() { int n, array[100], i; cout<<"number of digits in your no.=\n"; cin>>n; cout<<"enter numbers=\n"; for(i=0; i<n; i++) cin>>array[i]; cout<<"reverse no. is=\n"; for(i=n-1; i>=0; i--) cout<<array[i]; return 0; }

20th May 2019, 10:15 AM
Ragini Mishra
Ragini Mishra - avatar
7 Antworten
0
Check this line : for(i=0; i<n; i++); you have a semicolon
20th May 2019, 10:28 AM
Prokopios Poulimenos
Prokopios Poulimenos - avatar
0
Still does not work
20th May 2019, 10:29 AM
Ragini Mishra
Ragini Mishra - avatar
0
Add your code in playground and add one number per line : For example, 3 1 2 5 the result is 521 It works as expected
20th May 2019, 10:31 AM
Prokopios Poulimenos
Prokopios Poulimenos - avatar
0
Not yet
20th May 2019, 10:35 AM
Ragini Mishra
Ragini Mishra - avatar