Showing posts with label C++. Show all posts
Showing posts with label C++. Show all posts

Monday, April 16, 2012

100 C Aptitude Questions with Answers (Part 5)




81)          main(int argc, char **argv)

{

printf("enter the character"); 
getchar(); 
sum(argv[1],argv[2]);
}

sum(num1,num2) int num1,num2;
{

return num1+num2;

}

100 C Aptitude Questions with Answers (Part 4)




61)          main()

{

char *cptr,c;
void *vptr,v; c=10; v=0;
cptr=&c; vptr=&v;

printf("%c%v",c,v);

}

100 C Aptitude Questions with Answers (Part 3)




41)         
 #include<stdio.h>
main()
{
        struct xx
        {
                int x=3;
                char name[]="hello";
         };
         struct xx *s=malloc(sizeof(struct xx));
         printf("%d",s->x);
         printf("%s",s->name);
}

100 C Aptitude Questions with Answers (Part 2)




21.
#define square(x) x*x 
main()
{
        int i;
        i = 64/square(4);
        printf("%d",i);
}

100 C Aptitude Questions with Answers (Part 1)




It is assumed that,
# Programs run under DOS environment,
# The underlying machine is an x86 system,
# Program is compiled using Turbo C/C++ compiler.

# The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).


Tuesday, April 03, 2012

C and C++ 2006


1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived
object,. calling of that virtual method will result in which method being called? 
a. Base method
b. Derived method..

Ans. b