Array names and pointers can be used interchangeably in many contexts.
Which of the following format specifiers is used to represent the hours in the 24-hour clock (0-23) format?
What is the output of this C code?
int main()
{
int a = 2;
int b = 0;
int y = (b == 0) ? a :(a > b) ? (b = 1): a;
printf("%d\n", y);
}
What is the output of the following C code?
#include <stdio.h>
int main()
{
int n = 10;
for(;--n;);
printf("%d", n);
return 0;
}
What is the output of the following C program?
int main()
{
int a[3] = {0}, i;
static int b[3];
for (i = 0; i < 3; i++)
printf("%d %d\n", a[i], b[i]);
}
What will be the output of the following C++ code?
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v;
for (int i = 1; i <= 5; i++)
v.push_back(i);
cout << v.size() << endl;
v.resize(4);
cout << v.size() << endl;
return 0;
}
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
class Add
{
int x;
public:
Add(int x){
this->x = x;
}
int operator()(int a){
return x + a;
}
};
int main()
{
Add add_5(5);
int a = 5;
cout << add_5(a);
return 0;
}
What is the output of the following C++ code?
#include <iostream>
using namespace std;
class A
{
public:
virtual void fun();
};
class B
{
public:
void fun();
};
int main()
{
int a = sizeof(A), b = sizeof(B);
if (a == b) cout << "a == b";
else if (a > b) cout << "a > b";
else cout << "a < b";
return 0;
}
Pick out the correct statement about virtual functions.