CPP

CPP

Comments and Indentation has 9 Questions
How many types of comments are there in c++?

1
2
3
4
What is a comment in c++?

comments are parts of the source code disregarded by the compiler
comments are executed by compiler to find the meaning of the comment
comments are executable
none of the mentioned
What type of comments does c++ support?

single line
multi line
single line and multi line
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         /* this is comment*
  6. ?       cout << "hello world";
  7. ?       return 0;
  8. ?   }

hello world
hello
compile time error
none of the mentioned
What is the use of the indentation in c++?

distinguishes between comments and code
r distinguishes between comments and outer data
both a and b
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     long factorial (long a)
  4.     {
  5.         if (a > 1)
  6.             return (a * factorial (a + 1));
  7.         else
  8.             return (1);
  9.     }
  10.     int main ()
  11.     {
  12.         long num = 3;
  13.         cout << num << "! = " << factorial ( num );
  14.         return 0;
  15.     }

6
24
segmentation fault
compile time error
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     void square (int *x)
  4.     {
  5. 	*x = (*x + 1) * (*x);
  6.     }
  7.     int main ( )
  8.     {
  9. 	int num = 10;
  10.         square(&num);
  11. 	cout << num;
  12. 	return 0;
  13.     }

100
compile time error
144
110
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int add(int a, int b);
  4.     int main()
  5.     {
  6.         int i = 5, j = 6;
  7.         cout << add(i, j) << endl;
  8.         return 0;
  9.     }
  10.     int add(int a, int b )
  11.     {
  12.         int sum = a + b;
  13.         a = 7;
  14.         return a + b;
  15.     }

11
12
13
compile time error
What is used to write multi line comment in c++?

/* .... */
/$ .... $/
//
none of the mentioned