61. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void print(int i)
{
cout << i;
}
void print(double f)
{
cout << f;
}
int main(void)
{
print(5);
print(500.263);
return 0;
}
#include <iostream>
using namespace std;
void print(int i)
{
cout << i;
}
void print(double f)
{
cout << f;
}
int main(void)
{
print(5);
print(500.263);
return 0;
}
62. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
#define SquareOf(x) x * x
int main()
{
int x;
cout << SquareOf(x + 4);
return 0;
}
#include <iostream>
using namespace std;
#define SquareOf(x) x * x
int main()
{
int x;
cout << SquareOf(x + 4);
return 0;
}
63. Pick the incorrect statement for namespaces in C++.
64. What will be the output of the following C++ code?
#include <iostream>
#include <stdarg.h>
using namespace std;
int add (int num, ...)
{
int sum = 0;
va_list args;
va_start (args,num);
for (int i = 0; i < num; i++)
{
int num = va_arg (args,int);
sum += num;
}
va_end (args);
return sum;
}
int main (void)
{
int total = add(8, 1, 2, -1, 4, 12, -2, 9, 7);
cout << "The result is " << total;
return 0;
}
#include <iostream>
#include <stdarg.h>
using namespace std;
int add (int num, ...)
{
int sum = 0;
va_list args;
va_start (args,num);
for (int i = 0; i < num; i++)
{
int num = va_arg (args,int);
sum += num;
}
va_end (args);
return sum;
}
int main (void)
{
int total = add(8, 1, 2, -1, 4, 12, -2, 9, 7);
cout << "The result is " << total;
return 0;
}
65. What will happen when the exception is not caught in the program?
66. What should be passed in parameters when function does not require any parameters?
67. How many types do functions fall depends on modularization?
68. What will be the output of the following C++ code?
#include <iostream>
#include <stdarg.h>
using namespace std;
void dumplist(int, ...);
int main()
{
dumplist(2, 4, 8);
dumplist(3, 6, 9, 7);
return 0;
}
void dumplist(int n, ...)
{
va_list p;
int i;
va_start(p, n);
while (n-->0)
{
i = va_arg(p, int);
cout << i;
}
va_end(p);
}
#include <iostream>
#include <stdarg.h>
using namespace std;
void dumplist(int, ...);
int main()
{
dumplist(2, 4, 8);
dumplist(3, 6, 9, 7);
return 0;
}
void dumplist(int n, ...)
{
va_list p;
int i;
va_start(p, n);
while (n-->0)
{
i = va_arg(p, int);
cout << i;
}
va_end(p);
}
69. Which keyword is used to access the variable in the namespace?
70. Where can the default parameter be placed by the user?
Read More Section(Functions and Procedures in C plus plus)
Each Section contains maximum 100 MCQs question on Functions and Procedures in C plus plus. To get more questions visit other sections.