Showing posts with label C Interview Questions. Show all posts
Showing posts with label C Interview Questions. Show all posts

C Interview Questions - 8

Tuesday, March 18, 2008

  • What is the output of printf("%d")
  • What will happen if I say delete this
  • What is Dangling pointer?
  • Difference between "C structure" and "C++ structure".
  • Diffrence between a "assignment operator" and a "copy constructor"
  • What is the difference between "overloading" and "overridding"?
  • Explain the need for "Virtual Destructor".
  • Can we have "Virtual Constructors"?
  • What are the different types of polymorphism?
  • What are Virtual Functions? How to implement virtual functions in "C"
  • What are the different types of Storage classes?
  • What is Namespace?
  • What are the types of STL containers?.
  • Is there any difference between a messageand method?
  • If I ask you to write 'VI' editor in C++ - How you'll proceed?
  • Difference between char name[] = “mindgrill q”; and char *name = “mindgrill q”;
  • Should we use global variables?
  • Parsing HTML or XML document with C++
  • What is 'self assignment'?
  • Difference between how virtual and non-virtual member functions are called
  • Finding shortest path aka Dijkstra's algorithm and backtracking
  • Doing permutations and combinations in C++
  • Difference between "vector" and "array"?
  • How to write a program such that it will delete itself after exectution?
  • Can we generate a C++ source code from the binary file?
  • What are inline functions?
  • Talk sometiming about profiling?
  • How many lines of code you have written for a single program?
  • What is "strstream" ?
  • How to write Multithreaded applications using C++?
  • Explain "passing by value", "passing by pointer" and "passing by reference"
  • Write any small program that will compile in "C" but not in "C++"
  • Have you heard of "mutable" keyword?
  • What is a "RTTI"?
  • Is there something that I can do in C and not in C++?
  • Why preincrement operator is faster than postincrement?
  • What is the difference between "calloc" and "malloc"?
  • What will happen if I allocate memory using "new" and free it using "free" or allocate sing "calloc" and free it using "delete"?
  • What is Memory Alignment?
  • Explain working of printf.
  • Difference between "printf" and "sprintf".
  • What is "map" in STL?
  • When shall I use Multiple Inheritance?
  • What are the techniques you use for debugging?
  • How to reduce a final size of executable?
  • Give 2 examples of a code optimization.

Read more...

C Interview Questions - 7

  • What is linklist and why do we use it when we have arrays? - I feel correct answer should be linklist is used in cases where you don’t know memory required to store data structure and need to allocate is dynamically on demand.
  • What is maximum combined length of command line arguments including space between adjacent arguments?
  • What is near, far and huge pointers? How many bytes are occupied by them?
  • What is object file? How can you access object file?
  • What is pointer?
  • What is recursion?
  • What is similarity between Structure, Union and enumeration?
  • What is static identifier?
  • What is structure?
  • What is use of typedef?
  • When reallocating memory if any other pointers point into same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
  • Where are auto variables stored?
  • Where does global, static, local, register variables, free memory and C Program instructions get stored?
  • Write down equivalent pointer expression for referring same element a[i][j][k][l]?
  • advantages of using pointers in program?
  • advantages of using typedef in program?
  • bit fields? What is use of bit fields in Structure declaration?
  • declare following:
    array of three pointers to chars,
    array of three char pointers,
    pointer to array of three chars,
    pointer to function that receives int pointer and returns float pointer,
    pointer to function that receives nothing and returns nothing
  • detect loop in linked list?
  • differences between malloc() and calloc()?
  • differences between structures and arrays?
  • different storage classes in C?
  • dynamically allocate one-dimensional and two-dimensional array of integers?
  • enumerations?
  • implement substr() function that extracts sub string from given string?
  • macros? advantages and disadvantages?
  • obtain current time and Difference : two times?
  • obtain segment and offset addresses from far address of memory location?
  • print string on printer?
  • register variables? advantage of using register variables?
  • that function should be used to free memory allocated by calloc()?
  • that header file should you include if you are to develop function that can accept variable number of arguments?

Read more...

C Interview Questions - 6

  • How can called function determine number of arguments that have been passed to it?
  • How can we check whether contents of two structure variables are same or not?
  • How can we read/write Structures from/to data files?
  • How much maximum can you allocate in single call to malloc()?
  • How will you declare array of three function pointers where each function receives two ints and returns float?
  • If we want that any wildcard characters in command line arguments should be appropriately expanded, are we required to make any special provision? If yes, that?
  • In header file whether functions are declared or defined?
  • In header files whether functions are declared or defined?
  • Increase size of dynamically allocated array?
  • Increase size of statically allocated array?
  • Out of fgets() and gets() that function is safe to use and why?
  • Program : compare two strings without using strcmp() function.
  • Program : concatenate two strings.
  • Program : find Factorial of number.
  • Program : generate Fibonacci Series?
  • Program : interchange variables without using third one.
  • Program : s for String Reversal. same for Palindrome check.
  • Program : that employs Recursion?
  • Program : that uses command line arguments.
  • Program : that uses functions like strcmp(), strcpy(), etc.
  • To that numbering system can binary number be easily converted to?
  • Use bsearch() function to search name stored in array of pointers to string?
  • Use functions fseek(), freed(), fwrite() and ftell()?
  • Use functions memcpy(), memset(), memmove()?
  • Use functions randomize() and random()?
  • Use functions sin(), pow(), sqrt()?
  • Use qsort() function to sort array of structures?
  • Use qsort() function to sort name stored in array of pointers to string?
  • What advantages of using Unions?
  • What do functions atoi(), itoa() and gcvt() do?
  • What do ‘c’ and ‘v’ in argc and argv stand for?
  • What does error ‘Null Pointer Assignment’ mean and what causes this error?
  • What does static variable mean?
  • What is NULL Macro? Difference : NULL Pointer and NULL Macro?
  • What is NULL Pointer? Whether it is same as uninitialized pointer?
  • What is far pointer? where we use it?

Read more...

C Interview Questions - 5

  • Are expressions arr and *arr same for array of integers?
  • Are variables argc and argv are local to main?
  • Bitwise operator for checking whether particular bit is on or off?
  • Bitwise operator for putting on particular bit in number?
  • Bitwise operator for turning off particular bit in number?
  • Can Structure contain Pointer to itself?
  • Can there be at least some solution to determine number of arguments passed to variable argument list function?
  • Can we specify variable field width in scanf() format string? If possible how?
  • Can you dynamically allocate arrays in expanded memory?
  • Can you use function fprintf() to display output on screen?
  • Can you write function similar to printf()?
  • Describe about storage allocation and scope of global, extern, static, local and register variables?
  • Difference : Strings and Arrays?
  • Difference : Structure and Unions?
  • Difference : arrays and linked list?
  • Difference : enumeration and set of pre-processor # defines?
  • Difference : functions memmove() and memcpy()?
  • Difference : functions rand(), random(), srand() and randomize()?
  • Difference : main() in C and main() in C++?
  • Difference : pass by reference and pass by value?
  • Difference : strdup and strcpy?
  • Differentiate between for loop and while loop? it uses?
  • Does mentioning array name gives base address in all contexts?
  • Does there exist any other function that can be used to convert integer or float to string?
  • Does there exist any way to make command line arguments available to other functions without passing them as arguments to function?
  • Explain one method to process entire string as one unit?
  • How are Structure passing and returning implemented by complier?

Read more...

C Interview Questions - 4

Thursday, November 29, 2007

11. What will be printed as the result of the operation below:

main()
{
int x=10, y=15;
x = x++;
y = ++y;
printf(“%d %d\n”,x,y);
}

Answer: 11, 16

12. What will be printed as the result of the operation below:

main()
{
int a=0;
if(a==0)
printf(“MindgrillQ Systems\n”);
printf(“MindgrillQ Systems\n”);
}

Answer: Two lines with “MindgrillQ Systems” will be printed.

13. Write a function that swaps the values of two integers, using int* as the argument type.

void swap(int* a, int*b)
{
int t;
t = *a;
*a = *b;
*b = t;
}

14. Write a program that ask for user input from 5 to 9 then calculate the average

#include "iostream.h"
int main()
{
int MAX = 4;
int total = 0;
int average;
int numb;
for (int i=0; icout << "Please enter your input between 5 and 9: ";
cin >> numb;
while ( numb<5>9)
{
cout << "Invalid input, please re-enter: ";
cin >> numb;
}
total = total + numb;
}
average = total/MAX;
cout << "The average number is: " << return 0;
}

Read more...

C Interview Questions - 3

6. What will be printed as the result of the operation below:

main()
{
char s1[]=“MindgrillQ”;
char s2[]= “systems”;
printf(“%s”,s1);
}

Answer: MindgrillQ

7. What will be printed as the result of the operation below:

main()
{
char *p1;
char *p2;

p1=(char *)malloc(25);
p2=(char *)malloc(25);

strcpy(p1,”MindgrillQ”);
strcpy(p2,“systems”);
strcat(p1,p2);

printf(“%s”,p1);

}

Answer: MindgrillQsystems

8. The following variable is available in file1.c, who can access it?:

static int average;

Answer: all the functions in the file1.c can access the variable.

9. WHat will be the result of the following code?

#define TRUE 0 // some code

while(TRUE)
{
// some code
}

Answer: This will not go into the loop as TRUE is defined as 0.

10. What will be printed as the result of the operation below:

int x;
int modifyvalue()
{
return(x+=10);
}

int changevalue(int x)
{
return(x+=1);
}

void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output:%d\n",x);

x++;
changevalue(x);
printf("Second output:%d\n",x);
modifyvalue();
printf("Third output:%d\n",x);

}

Answer: 12 , 13 , 13

Read more...

C Interview Questions - 2

1. What will print out?
main()
{
char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);
printf(“%s\n”,p2);
}

Answer:empty string.

2. What will be printed as the result of the operation below:
main()
{
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%d\n”,x,y);
}

Answer : 5794

3. What will be printed as the result of the operation below:
main()
{
int x=5;
printf(“%d,%d,%d\n”,x,x< <2,x>>2);
}

Answer: 5,20,1

4. What will be printed as the result of the operation below:
#define swap(a,b) a=a+b;b=a-b;a=a-b;

void main()
{
int x=5, y=10;
swap (x,y);
printf(“%d %d\n”,x,y);
swap2(x,y);
printf(“%d %d\n”,x,y);
}

int swap2(int a, int b)
{
int temp;
temp=a;
b=a;
a=temp;
return 0;
}

Answer: 10, 5 10, 5

5. What will be printed as the result of the operation below:
main()
{
char *ptr = ” MindgrillQ Systems”;
*ptr++; printf(“%s\n”,ptr);
ptr++;
printf(“%s\n”,ptr);
}

Answer:MindgrillQ Systems indgrillQ systems

Read more...

C Interview Questions - 1

Wednesday, November 28, 2007

1. Write a program in C to find the 3*3 matrix multiplication.

2. Write a program in C to find the complex number of a given number.

3. how to print all the combinations of a given integer.

4. what is the significance of following functions

  • freopen()
  • strtok()
  • access()
  • state()
5. what is the "escape hatch" provided by #pragma directive?

6. what is source code of this tringle ...
A
A N I
A N I R B
A N I R B A N
A N I R B A N P A
A N I R B A N P A U L

7. What happens when you overload the stack?

8. what do you mean by preprocessor directory?

9. What is byte offset of a field within a structure?

10. What is unabridged list?

11. How is structure passing and returning implemented?

12. Write sample code or algorithim to get all possible combinations of data that will be entered from keyboard.

13. Explian Floyd Cycle finding algorithm for circular link list?

14. Why is that a pointer is depicted by '*' in C?

15. Write a program to print an 2D array in spiral manner

16. #includevoid fun(int);void main(){ inta; a=3; fun(a); }void fun(int){ if(n>0) { fun(--n);...

17. Given the values of two nodes in a *binary search tree*, write a cprogram to find the lowest common ancestor.

18. Can we define an array without any constant expression? If Yes, How?

19. For what purpose pragma.h header file is used?

20. What is the advantage of zero filling in calloc() ?

Read more...

Chitika

About This Blog

Followers

  © Blogger template The Professional Template II by Ourblogtemplates.com 2009

Back to TOP