Question #275387

Make a program code reverse the display from N to 1 to 1-N, and how to accept the value N?

Expert's answer

#include <iostream>

int main(void) {
 int n;
 cin >> n; // accepting value of n from stdin
 for (int i = n; i > 0; i--)
  cout << i << " "; // print numbers from 1 to N in reverse order
 return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS