+ 1

Write a program to reverse print from 15 to 1?

plz try this program

17th May 2018, 2:50 PM
Baibhab Ghosal
4 Answers
+ 2
Python code: l = [] l.extend(range(1,16)) print(l[::-1])
17th May 2018, 3:20 PM
Rahul George
Rahul George - avatar
+ 1
plz give the answer in c++ and using class and object
17th May 2018, 3:21 PM
Baibhab Ghosal
+ 1
#include <iostream> // std::cout #include <algorithm> // std::reverse #include <vector> // std::vector int main () { std::vector<int> myvector; // set some values: for (int i=1; i<10; ++i) myvector.push_back(i); // 1 2 3 4 5 6 7 8 9 std::reverse(myvector.begin(),myvector.end()); // 9 8 7 6 5 4 3 2 1 // print out content: std::cout << "myvector contains:"; for (std::vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it) std::cout << ' ' << *it; std::cout << '\n'; return 0; }
17th May 2018, 3:29 PM
Rajeeb
0
#include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("\n"); //for new line // While Loop n=15; //Initialize while(n>=1) // Condition { printf(" %d",n); n--; // Decrement } getch(); }
17th May 2018, 3:02 PM
Rajeeb