What will be the output of the following C++ code?
How many runtime error messages are associated with exceptions?
What is the output of the following C program?
Which of the following is a static polymorphism mechanism?
What is the value of r in the following code?
#include <stdio.h>
void main()
{
int x = 4;
int *p = &x;
int *k = p++;
int r = p - k;
printf("%d", r);
}
What is the output of the following C program?
int main()
{
int arr[] = {0, 1, 2, 3, 4};
int *ptr, i;
for (ptr = arr + 4; ptr >= arr; ptr--)
printf("%d ", *ptr);
}
Let A[1...n] be an array of n distinct numbers. If i < j and A[i] > A[j], then the pair (i, j) is called an inversion of A. What is the expected number of inversions in any permutation on n elements ?
When will we use the function overloading?
What will be the output of the following C code?
main()
{
char s = '2';
switch(s)
{
case '1': printf("hi");
case '2': printf("hello");
default: printf("I am Parv");
}
printf("hello how are u");
}
#include <iostream>
using namespace std;
class CVector {
public:
int x,y;
CVector () {}
CVector (int a, int b) : x(a), y(b) {}
};
CVector operator+ (const CVector& lhs, const CVector& rhs) {
CVector temp;
temp.x = lhs.x + rhs.x;
temp.y = lhs.y + rhs.y;
return temp;
}
int main () {
CVector foo (3,1);
CVector bar (1,2);
CVector result;
result = foo + bar;
cout << result.x << ',' << result.y << '\n';
return 0;
}