What will be the output of the program ?
#include
int main()
{
union a
{
int i;
char ch[2];
}
union a u;
u.ch[0]=6;
u.ch[1]=7;
printf("%d\n", u.i);
return 0;
}
The system will allocate 2 bytes to the array
Write a program to find factorial of a number.
int main()
{
int x,i,fac;
fac=1;
printf("input the number whose factorial has to be found");
scanf("%d", &x);
for(i=x; i>0,i--)
{
fac= fac*i;
}
u.i is calculated as
(6)(7) in binary form which is equal to 1798.
2+4+256+512+1024=1798
Which of the following is similar to constructor overloading?
Operator overloading
Destructor overloading
Function overloading
None of the above
Answer: Option C.
In function overloading, we will be using the same options availed in constructor overloading.
Which of the following is a branch of polymorphism?
Overloading
Inheritance
Encapsulation
None of these
Answer: Option A.
Which of the following is feature of friend classes?
If class A is a friend of class B, class B is not automatically a friend of class A.
If class A is a friend of class B, and class B is a friend of class C, class A is not automatically a friend of class C