+ 1
Write a program to reverse print from 15 to 1?
plz try this program
4 Respuestas
+ 2
Python code:
l = []
l.extend(range(1,16))
print(l[::-1])
+ 1
plz give the answer in c++ and using class and object
+ 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;
}
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(); }