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

Write a program for Divide a number with 2 and Print the output ( NOTE: Check for divide by zero error).

630


Does there exist any other function which can be used to convert an integer or a float to a string?

648


What is the difference between containment and delegation?

700


Explain deep copy?

606


What is null c++?

585






What is a class template in c++?

519


When is dynamic checking necessary?

597


What is object in c++ example?

622


List the types of polymorphism in c++?

622


Is c++ a difficult language?

572


In c++, what is the difference between method overloading and method overriding?

594


Difference between Abstraction and encapsulation in C++?

576


Who calls main function?

583


Can a new be used in place of old mallocq? If yes, why?

633


Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

602