In: Computer Science
7
6 5 4 3
2 1
C++ code
C++ code:
#include <iostream>
using namespace std;
int main(){
//initializing count and giving a sample value for n
int count=0,n=7;
//looping from n to 1
for(int i=n;i>=1;i--){
//incrementing count
count++;
//checking if count is not 5
if(count!=5)
//printing current number i
cout<<i<<" ";
else{
//initializing count as 0
count=0;
//printing i and ending line
cout<<i<<endl;
}
}
return 0;
}
Screenshot:
Output: