print first nodd numbers in descending order

Answer Posted / rabid manatee

#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {

int n = 4;

if (argc == 2) {
n = atoi(argv[1]);
}

for(int i=n; i >= 0; i--) {
cout << i*2 + 1 <<endl;
}

}

Is This Answer Correct ?    3 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many namespaces are there in c++?

642


Is java easier than c++?

682


What is the difference between equal to (==) and assignment operator (=)?

665


Why cstdlib is used in c++?

676


What are virtual constructors/destructors?

647






What is the use of class in c++?

661


What is the difference between while and do while loop?

666


Explain method of creating object in C++ ?

684


Which software is best for programming?

750


What is the difference between multiple and multilevel inheritance in c++?

716


List different attributes in C++?

731


Which is the best c++ compiler for beginners?

651


What is static in c++?

688


Program to check whether a word is a sub-string or not of a string typed

1683


an integer constant must have atleast one a) character b) digit c) decimal point

639