Using loop. Make a program code reverse
( from N to 1) (to 1 - N).
#include<iostream>
using namespace std;
int main(){
int i, N;
cout<<"Enter the ending value of N i.e 10: ";
cin>>N;
cout<<"Before reversing \t";
for(i=N;i>=1;i--){
cout<<i<<" ";
}
cout<<"\n\n";
cout<<"After reversing \t";
for(i=1;i<=N;i++){
cout<<i<<" ";
}
return 0;
}
Comments
Leave a comment