Q 16.)
#include
using namespace std;
class Base {
public:
Base()
{
foo();
}
virtual void f()
{
cout << "\nBase::f is being called\n";
}
void foo()
{
f();
}
};
class Derive : public Base {
public:
virtual void f()
{
cout << "\nDerive::f is being called\n";
}
};
int main()
{
Derive d; //Base::f is being called.. f being virtual.. Why derived f() is not being called..
}
why output is not expected..
Q.17)
int main()
{
int i=10, j=2;
int *ip= &i, *jp = &j;
int k = *ip/*jp;
printf("%d",k);
return 0;
}
Is it a valid c-program ? Give reasons.
Q.18)
int main()
{
float f=5,g=10;
enum{i=10,j=20,k=50};
printf("%d\n",++k);
printf("%f\n",f<<2);
printf("%lf\n",f%g);
printf("%lf\n",fmod(f,g));
}
What is the problem with this code ?
Q.19)
What is the output of this two codes:
int main()
{
signed char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}
int main()
{
unsigned char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}
Why is the difference?
Q.20)
int main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}
Is it a valid C program ? Give reasons.
#include
using namespace std;
class Base {
public:
Base()
{
foo();
}
virtual void f()
{
cout << "\nBase::f is being called\n";
}
void foo()
{
f();
}
};
class Derive : public Base {
public:
virtual void f()
{
cout << "\nDerive::f is being called\n";
}
};
int main()
{
Derive d; //Base::f is being called.. f being virtual.. Why derived f() is not being called..
}
why output is not expected..
Q.17)
int main()
{
int i=10, j=2;
int *ip= &i, *jp = &j;
int k = *ip/*jp;
printf("%d",k);
return 0;
}
Is it a valid c-program ? Give reasons.
Q.18)
int main()
{
float f=5,g=10;
enum{i=10,j=20,k=50};
printf("%d\n",++k);
printf("%f\n",f<<2);
printf("%lf\n",f%g);
printf("%lf\n",fmod(f,g));
}
What is the problem with this code ?
Q.19)
What is the output of this two codes:
int main()
{
signed char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}
int main()
{
unsigned char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}
Why is the difference?
Q.20)
int main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}
Is it a valid C program ? Give reasons.
0 comments:
Post a Comment