Frequently asked Questions for Interview on C++

Leave a Comment

  1. What is a class?
  2. What is an object?
  3. What is the difference between an object and a class?
  4. What is the difference between class and structure?
  5. What is public, protected, private?
  6. What are virtual functions?
  7. What is friend function?
  8. What is a scope resolution operator?
  9. What do you mean by inheritance?
  10. What is abstraction?
  11. What is polymorphism? Explain with an example.
  12. What is encapsulation?
  13. What do you mean by binding of data and functions?
  14. What is function overloading and operator overloading?
  15. What is virtual class and friend class?
  16. What do you mean by inline function?
  17. What do you mean by public, private, protected and friendly?
  18. When is an object created and what is its lifetime?
  19. What do you mean by multiple inheritance and multilevel inheritance? Differentiate between them.
  20. Difference between realloc() and free?
  21. What is a template?
  22. What are the main differences between procedure oriented languages and object oriented languages?
  23. What is R T T I ?
  24. What are generic functions and generic classes?
  25. What is namespace?
  26. What is the difference between pass by reference and pass by value?
  27. Why do we use virtual functions?
  28. What do you mean by pure virtual functions?
  29. What are virtual classes?
  30. Does c++ support multilevel and multiple inheritance?
  31. What are the advantages of inheritance?
  32. When is a memory allocated to a class?
  33. What is the difference between declaration and definition?
  34. What is virtual constructors/destructors?
  35. In c++ there is only virtual destructors, no constructors. Why?
  36. What is late bound function call and early bound function call? Differentiate.
  37. How is exception handling carried out in c++?
  38. When will a constructor executed?
  39. What is Dynamic Polymorphism?
  40. Write a macro for swapping integers.
Read More...

Frequently asked questions in C for Placement interview

Leave a Comment

  1. What does static variable mean?
  2. What is a pointer?
  3. What is a structure?
  4. What are the differences between structures and arrays?
  5. In header files whether functions are declared or defined? 
  6. What are the differences between malloc() and calloc()?
  7. What are macros? what are its advantages and disadvantages?
  8. Difference between pass by reference and pass by value?
  9. What is static identifier?
  10. Where are the auto variables stored?
  11. Where does global, static, local, register variables, free memory and C Program instructions get stored?
  12. Difference between arrays and linked list?
  13. What are enumerations?
  14. Describe about storage allocation and scope of global, extern, static, local and register variables?
  15. What are register variables? What are the advantage of using register variables?
  16. What is the use of typedef?
  17. Can we specify variable field width in a scanf() format string? If possible how?
  18. Out of fgets() and gets() which function is safe to use and why?
  19. Difference between strdup and strcpy?
  20. What is recursion?
  21. Differentiate between a for loop and a while loop? What are it uses?
  22. What are the different storage classes in C?
  23. Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
  24. What is difference between Structure and Unions?
  25. What the advantages of using Unions?
  26. What are the advantages of using pointers in a program?
  27. What is the difference between Strings and Arrays?
  28. In a header file whether functions are declared or defined?
  29. What is a far pointer? where we use it?
  30. How will you declare an array of three function pointers where each function receives two ints and returns a float?
  31. what is a NULL Pointer? Whether it is same as an uninitialized pointer?
  32. What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
  33. What does the error 'Null Pointer Assignment' mean and what causes this error?
  34. What is near, far and huge pointers? How many bytes are occupied by them?
  35. How would you obtain segment and offset addresses from a far address of a memory location?
  36. Are the expressions arr and &arr same for an array of integers?
  37. Does mentioning the array name gives the base address in all the contexts?
  38. Explain one method to process an entire string as one unit?
  39. What is the similarity between a Structure, Union and enumeration?
  40. Can a Structure contain a Pointer to itself?
  41. How can we check whether the contents of two structure variables are same or not?
  42. How are Structure passing and returning implemented by the complier?
  43. How can we read/write Structures from/to data files?
  44. What is the difference between an enumeration and a set of pre-processor # defines?
  45. what do the 'c' and 'v' in argc and argv stand for?
  46. Are the variables argc and argv are local to main?
  47. What is the maximum combined length of command line arguments including the space between adjacent arguments?
  48. If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
  49. Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
  50. What are bit fields? What is the use of bit fields in a Structure declaration?
  51. To which numbering system can the binary number 1101100100111100 be easily converted to?
  52. Which bit wise operator is suitable for checking whether a particular bit is on or off?
  53. Which bit wise operator is suitable for turning off a particular bit in a number?
  54. Which bit wise operator is suitable for putting on a particular bit in a number?
  55. Which bit wise operator is suitable for checking whether a particular bit is on or off?
  56. which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
  57. Write a program to compare two strings without using the strcmp() function.
  58. Write a program to concatenate two strings.
  59. Write a program to interchange 2 variables without using the third one.
  60. Write programs for String Reversal & Palindrome check
  61. Write a program to find the Factorial of a number
  62. Write a program to generate the Fibinocci Series
  63. Write a program which employs Recursion
  64. Write a program which uses Command Line Arguments
  65. Write a program which uses functions like strcmp(), strcpy()? etc
  66. What are the advantages of using typedef in a program?
  67. How would you dynamically allocate a one-dimensional and two-dimensional array of integers?
  68. How can you increase the size of a dynamically allocated array?
  69. How can you increase the size of a statically allocated array?
  70. When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
  71. Which function should be used to free the memory allocated by calloc()?
  72. How much maximum can you allocate in a single call to malloc()?
  73. Can you dynamically allocate arrays in expanded memory?
  74. What is object file? How can you access object file?
  75. Which header file should you include if you are to develop a function which can accept variable number of arguments?
  76. Can you write a function similar to printf()?
  77. How can a called function determine the number of arguments that have been passed to it?
  78. Can there be at least some solution to determine the number of arguments passed to a variable argument list function?
  79. How do you declare the following:
    • An array of three pointers to chars
    • An array of three char pointers
    • A pointer to array of three chars
    • A pointer to function which receives an int pointer and returns a float pointer
    • A pointer to a function which receives nothing and returns nothing
  80. What do the functions atoi(), itoa() and gcvt() do?
  81. Does there exist any other function which can be used to convert an integer or a float to a string?
  82. How would you use qsort() function to sort an array of structures?
  83. How would you use qsort() function to sort the name stored in an array of pointers to string?
  84. How would you use bsearch() function to search a name stored in array of pointers to string?
  85. How would you use the functions sin(), pow(), sqrt()?
  86. How would you use the functions memcpy(), memset(), memmove()?
  87. How would you use the functions fseek(), freed(), fwrite() and ftell()?
  88. How would you obtain the current time and difference between two times?
  89. How would you use the functions randomize() and random()?
  90. How would you implement a substr() function that extracts a sub string from a given string?
  91. What is the difference between the functions rand(), random(), srand() and randomize()?
  92. What is the difference between the functions memmove() and memcpy()?
  93. How do you print a string on the printer?
  94. Can you use the function fprintf() to display the output on the screen? 
Read More...

Technical Aptitude Question Paper for Practice :: #Campus Placement

Leave a Comment


  1.  #include<stdio.h>
int main()
{
char ch;
while (x=0;x<=255;x++)
printf("ASCII value of %d character %c\n", x, x);
return 0;
}
A. The code generates an infinite loop B. The code prints all ASCII values and its characters
C. Error: x undeclared identifier D. Error: while statement missing

  1. #include<stdio.h>
int main()
{
int i,
a[] = {2, 4, 6, 8, 10};
change(a, 5);
for(i=0; i<=4; i++)
printf("%d, ", a[i]);
return 0;
}
change(int *b, int n)
{
int i;
for(i=0; i<n; i++)
*(b+1) = *(b+i)+5;
}
A. 7, 9, 11, 13, 15 B. 2, 15, 6, 8, 10 C. 2 4 6 8 10 D. 3, 1, -1, -3, -5

3) #include<stdio.h>
int fun(int, int);
typedef int (*pf) (int, int);
int proc(pf, int,int);
int main()
{
printf("%d\n", proc(fun, 6, 6));
return 0;
}
int fun(int a, int b)
{
return (++a!=b++);
}
int proc(pf p, int a, int b)
{
return ((*p)(a, b));
}
A. 6 B. 1 C. 0 D. -1
4) main()
{
fork();
fork();
fork();
printf("Hello World!");
}
A. compiler error B. print hello world 4 time
C. print hello world 6 time D. print hello world 8 time

5) C program code –
int zap(int n)
{
if(n<=1)then zap=1;
else zap=zap(n-3)+zap(n-1);
}
then the call zap(6) gives the values of zap

A. 8 B. 9 C. 6 D. 12 E. 15

6) Virtual memory size depends on
A. address lines B. data bus C. disc space D. A & C E. None

7) What will be the output of the following program :
struct {
int i, val[25];
}var={1,2,3,4,5,6,7,8,9},*vptr=&var;
void main()
{
printf("%d %d %d\n",var.i,vptr->i,(*vptr).i);
printf("%d %d %d %d %d %d",var.val[4],*(var.val+4),vptr->val[4],*(vptr->val+4),
(*vptr).val[4],*((*vptr).val+4));
}
  1. Compile-Time Error B. 1 1 1 C. 1 1 1 D. None of these
666666 555555

8) What will be the output of the following program :
struct my_struct1{
int arr[2][2];
};
typedef struct my_struct1 record;
struct my_struct2{
record temp;
}list[2]={1,2,3,4,5,6,7,8};
void main()
{
int i,j,k;
for (i=1; i>=0; i--)
for (j=0; j<2; j++)
for (k=1; k>=0; k--)
printf("%d",list[i].temp.arr[j][k]);
}
  1. Compile-Time Error B. Run-Time Error C. 65872143 D. 56781243

9) What will be the output of the following program :
union A{
char ch;
int i;
float f;
}tempA;
void main()
{
tempA.ch='A';
tempA.i=777;
tempA.f=12345.12345;
printf("%d",tempA.i);
}
  1. Compile-Time Error B. 12345 C. Erroneous output D. 777

10) What will be the output of the following program :
struct A{
int i;
float f;
union B{
char ch;
int j;
}temp;
}temp1;
void main()
{
struct A temp2[5];
printf("%d %d",sizeof temp1,sizeof(temp2));
}
A. 12 60 B. 60 12 C. compile time error D. none

11) What will be the output of the following program?
void main()
{
static struct my_struct{
unsigned a:1;
unsigned b:2;
unsigned c:3;
unsigned d:4;
unsigned :6; // Fill out first word
}v={1,2,7,12};
printf("%d %d %d %d",v.a,v.b,v.c,v.d);
printf("%d ",sizeof v);
}
  1. 1 2 7 12 4 B. 12 7 2 1 2 C. compile time error D. none

12) What will be the output of the following program :
void main()
{
printf();
}
  1. Run-Time Error B. Compile-Time Error C. No Output D. None of these

13)What will be the output of the following program :
void main()
{
printf("%d",printf("Hi!")*printf("Bye"));
}
  1. ByeHi!6 B. Hi!Bye9 C. Hi!Bye D. None of these

14) What will be the output of the following program :
#define Compute(x,y,z) (x+y-z)
void main()
{
int x=2,y=3,z=4;
printf("%d",Compute(y,z,(-x+y)) * Compute(z,x,(-y+z)));
}
  1. 20 B. 30 C. 100 D. None

15)What will be the output of the following program :
void main()
{
int i;
float a[5];
for (i=0; i<5; i++)
a[i] = (printf, ("%d",i/10.0));
for (i=0; i<5; i++)
printf("%.1f ",a[i]);
}
  1. Compile-Time Error B. 0.0 0.0 0.0 0.0 0.0 C. 0.0 0.1 0.2 0.3 0.4 D. 1.0 1.0 1.0 1.0 1.0

16) What will be the output of the following program :
int * func()
{
int temp=50;
return&temp;
}
void main()
{
int *val;
val = func();
printf("%d",*val);
}
  1. Compile-Time Error B. 50 C. Garbage Value D. None of these

17) What will be the output of the following program :
void main()
{
long double val;
printf("%d bytes",sizeof(val));
}
  1. Compile-Time Error B. 4 bytes C. 8 bytes D. 10 bytes

18) What will be the output of the following program :
#define Loop(i) for (j=0; j<i; j++){ \
sum += i+j; \
}
void main()
{
int i,j,sum=0;
for (i=0; i<=3; i++)
Loop(i)
printf("%d",sum);
}
  1. Run-Time Error B. Compile-Time Error C. 18 D.0

19) What will be the output of the following program :
void main()
{
int i;
for (i=5; ++i; i-=3)
printf("%d ",i);
}
  1. 6 4 2 B. Compile-Time Error C. 6 3 1 D. Infinite Loop


20) What will be the output of the following program :
void main()
{
static int j;
for (j<5; j<5; j+=j<5)
printf("%d",j++);
}
  1. 024 B. Compile-Time Error C. 01234 D. No Output

21) What will be the output of the following program :
void main()
{
for (;printf(""););
}
  1. Compile-Time error B. NO OUTPUT C. Executes INFINITELY D. None of these

22) What will be the output of the following program :
void main()
{
static int choice;
switch(--choice,choice-1,choice-1,choice+=2)
{
case 1:
printf("Choice1");
break;
case 2:
printf("Choice2");
break;
default:
printf("Default");
}
}
  1. Choice1 B. Choice2 C. Default D. Compile error

23) What will be the output of the following program?
int funct(char ch)
{
ch=ch+1;
return ch;
}
void main()
{
int a=127;
printf("%d %d",a,funct(a));
}
  1. Compile-Time Error B. 127 128 C. 127 -128 D. None of these

24)What will be the output of the following program :
int funct1(int a)
{
if (a)
return funct1(a--)+a;
else
return 0;
}
void main()
{
int a=3;
printf("%d",funct1(a));
}
  1. 3 B. 6 C. 0 D. stack overflow

25) What will be the output of the following program :
void main()
{
int (*a)[5];
printf("%d %d",sizeof(*a),sizeof(a));
}
  1. Compile-Time Error B. 2 10 C. 4 20 D. 20 4

26) What will be the output of the following program :
void main()
{
int val=77;
const int const *ptr=&val;
printf("%d",*ptr);
}
  1. Compile-Time Error B. Run-Time Error C. 77 D. None of these

27)What will be the output of the following program :
void main()
{
char str[]="yagyesh kumar mishra";
printf("%d",++(sizeof(str)));
}
  1. 14 B. Compile-Time Error C. 15 D. run-time error

28) What will be the output of the following program :
void main()
{
int a=1,b=2,c=3;
c=(--a,b++)-c;
printf("%d %d %d",a,b,c);
}
  1. 0 3 -3 B. Compile-Time Error C. 0 3 -1 D. 0 3 0

29) What will be the output of the following program :
#define swap(a,b) temp=a; a=b; b=temp;
void main()
{
static int a=5,b=6,temp;
if (a > b)
swap(a,b);
printf("a=%d b=%d",a,b);
}
  1. a=5 b=6 B. a=6 b=5 C. a=6 b=0 D. None of these

30) What is the difference between class and structure?

_____________________________________________________________________________________
31) Write a macro "SWAP(a,b)" for swapping integers using bit wise operator XOR.

_____________________________________________________________________________________
32)What is virtual function?

_____________________________________________________________________________________
33) - ls command stores contents in
A. inode block B. process table C. directry entry D. current directory

34) startup programme of window : autoexec.bat :: startup program of Unix : ?
A. .profile B. autoexeclp C. getty D. csh

35) Semaphore is used for _____________________of multiple process

36) FTP transfer file with user authentication. (TRUE/FALSE)

37) In signed magnitude notation what is the minimum value that can be represented with 8 bits
A. -128 B. -255 C. -127 D. 0

38) abcD+abcd+aBCd+aBCD
then the simplified function is –
( Capital letters are copliments of corresponding letter for eg.A is compliment of a)
Hint - use boolean arithmatic.
A. a B. abc C. abcd D. a(bC+Bc) E. a(bC +BC)

39) A 12 address lines maps to the memory of_________
A. 1k bytes B. 0.5k bytes C. 4k bytes D. None

40). What does DLL stands for ?
A. Dynamic Language Library B. Dynamic Link Library
C. Dynamic Load Library D. None of the above

41) SNAPSHOT is used for
A. Synonym B. Table space C. System server D. Dynamic data replication

42. A Transaction ends
A. Only when it is Committed B. Only when it is Rolledback
C. When it is Committed or Rolled back D. None of the above


43) A Database Procedure is stored in the Database
A. In compiled form B. As source code C. Both A & B D. Not stored

44) A Stored Procedure is a
A. Sequence of SQL or PL/SQL statements to perform specific function
B. Stored in compiled form in the database
C. Can be called from all client environmets
D. All of the above

45) Which of the following is NOT VALID in PL/SQL ?
A. Select ... into B. Update C. Create D. Delete

46) What are the different events in Triggers ?
A. Define, Create B. Drop, Comment C. Insert, Update, Delete D. All of the above

47)Which layer in the OSI model handles terminal emulation ?
A. Session B. Application C. Presentation D. Transport E. Network

48).An internet IP address of a node has to be unique for
A. domain of the node B. country C. sub-network of the node D. World-wide E. None

49) Modem stand for
A. Modulator/demodulators
B. Connect to multiple computers
C. Broadcast wireless signals
D. Only work with AOL

50) TCP is a connectionless protocol. TRUE/FALSE
Read More...