My Report

Advanced C++ Test – 2


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. To use command line arguments in C++, how many parameters are passed to the main function?

2. Which of the following gives the name of the program if the second parameter to the main fucntion is char **argv?

3. Which of the following is correct to interpret Hello World as a single argument?

1) $ ./output 'Hello World'
2) $ ./output Hello World

4. Which is the correct way of handling arguments with spaces?

5. Which of the following is correct about the second parameter of the main function?

6. What is the signature of math in function using command line arguments?

7. What are command line arguments?

8. Which of the following is correct about the first parameter of the main function?

9. What will be the output of the following C++ code if the following arguments are executed on terminal?

================program.cpp================
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	for(int i=0;i<argc;i++)
		cout<<argv[i]<<"\n";
}
=======================================
================commands===============
$ g++ program.cpp -o output
$ ./output Hello World
=======================================

10. What does the first parameter of the main function represent?

11. What does the second parameter of the main function represent?

12. Which character is used to separate different arguments?


 

Start practicing “1000 MCQs on C++”, and once you are ready, you can take tests on all topics by attempting our “C++ Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.