Techno World Inc - The Best Technical Encyclopedia Online!

THE TECHNO CLUB [ TECHNOWORLDINC.COM ] => C/C++/C# => Topic started by: Admin on October 13, 2006, 12:57:33 AM



Title: C/C++ Questions
Post by: Admin on October 13, 2006, 12:57:33 AM
C/C++ Questions

1. What is the output of printf("%d")
2. What will happen if I say delete this
3. Difference between "C structure" and "C++ structure".
4. Diffrence between a "assignment operator" and a "copy constructor"
5. What is the difference between "overloading" and "overridding"?
6. Explain the need for "Virtual Destructor".
7. Can we have "Virtual Constructors"?
8. What are the different types of polymorphism?
9. What are Virtual Functions? How to implement virtual functions in "C"
10. What are the different types of Storage classes?
11. What is Namespace?
12. What are the types of STL containers?.
13. Difference between "vector" and "array"?
14. How to write a program such that it will delete itself after exectution?
15. Can we generate a C++ source code from the binary file?
16. What are inline functions?
17. Talk sometiming about profiling?
18. How many lines of code you have written for a single program?
19. What is "strstream" ?
20. How to write Multithreaded applications using C++?
21. Explain "passing by value", "passing by pointer" and "passing by reference"
22. Write any small program that will compile in "C" but not in "C++"
23. Have you heard of "mutable" keyword?
24. What is a "RTTI"?
25. Is there something that I can do in C and not in C++?
26. Why preincrement operator is faster than postincrement?
27. What is the difference between "calloc" and "malloc"?
28. What will happen if I allocate memory using "new" and free it using "free" or allocate sing "calloc" and free it using "delete"?
29. What is Memory Alignment?
30. Explain working of printf.
31. Difference between "printf" and "sprintf".
32. What is "map" in STL?
33. When shall I use Multiple Inheritance?
34. What are the techniques you use for debugging?
35. How to reduce a final size of executable?
36. Give 2 examples of a code optimization.


Title: Re: C/C++ Questions
Post by: Admin on October 13, 2006, 12:58:00 AM
1.Study the Following Points:
a.One Cannot Take the address of a Bit Field
b.bit fields cannot be arrayed
c.Bit-Fields are machine Dependant
d.Bit-fields cannot be declared as static
Which of the Following Statements are true w.r.t Bit-Fields
A)a,b&c B)Only a & b C)Only c D)All

2.What is the function of ceil(X) defined in math.h do?
A)It returns the value rounded down to the next lower integer
B)it returns the value rounded up to the next higher integer
C)the Next Higher Value
D)the next lower value

3.When do you say that a digraph is acyclic
A)if and only if its first search does not have back arcs
B)a digraph is acyclic if and only if its first search does not have back vertices
C)if and only if its first search does not have same dfnumber
D)None of these

4.A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as:
A)int (*q(char*)) []
B)int *q(char*) []
C)int(*q)(char*) []
D)None of the Above

5.What kind of sorting is this:

SORT (k,n)
1.[Loop on I Index]
repeat thru step2 for i=1,2,........n-1
2.[For each pass,get small value]
min=i;
repeat for j=i+1 to N do
{
if K[j]min=j;
}
temp=K;K=K[min];K[min]=temp;
3.[Sorted Values will be returned]

A)Bubble Sort
B)Quick Sort
C)Selection Sort
D)Merge Sort

6.Which of the Following is not defined in string.h?
A)strspn()
B)strerror()
C)memchr()
D)strod()

7.Identify the correct argument for the function call fflush() in ANSI C:
A)stdout
B)stdin
C)stderr
D)All the above

8.Which of the Following will define a type NODE that is a node in a Linked list?
A)struct node {NODE*next;int x;};type def struct node NODE;
B)typedef struct NODE {struct NODE *next;int x;};
C)typedef struct NODE {NODE *next;int x;};
D)typedef struct {NODE *next;int x;}NODE;


9.Which of these statements are false w.r.t File Functions?
i)fputs() ii)fdopen() iii)fgetpos() iv)ferror()

A)ii B)i,ii C)iii D)iv

10.Study the code:
void show()
main()
{
show();
}
void show (char *s)
{
printf("%s\n",s);
}

What will happen if it is compiled & run on an ANSI C Compiler?
A)It will compile & nothing will be printed when it is executed
B)it will compile but not link
C)the compiler will generate an error
D)the compiler will generate a warning

11.Look at the Code:
#include
void main()
{
char s1[]="abcd";
char s2[10];
char s3[]="efgh";
int i;
clrscr();
i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd"));
printf("%d",i);
}

What will be the output?
A)No output B) A Non Integer C)0 D) Garbage

12.Look at the Code:
main()
{
int a[]={1,2,3},i;
for(i=0;i<3;i++)
{
printf("%d",*a);
a++;
}
}

Which Statement is/are True w.r.t the above code?
I.Executes Successfully & Prints the contents of the array
II.Gives the Error:Lvalue Required
III.The address of the array should not be changed
IV.None of the Above.

A)Only I B)Only II C)II & III D)IV

13.what is the output?
#define fun(a,b,t) (g ##t=(a),(a)=(b),(b)=g##t)
float gfloat;
main()
{
float a=1.12,b=3.14;
fun (a,b,float);
printf("\na=%4.2f,b=%4.2f",a,b);
}

A)Error in Defining Macro
B)a=1.12,b=3.14
C)a=3.14,b=1.12
D)None of teh Above

14.study the code:
#include
void main()
{
const int a=100;
int *p;
p=&a;
(*p)++;
printf("a=%d\n(*p)=%d\n",a,*p);
}
What is printed?

A)100,101 B)100,100 C)101,101 D)None of the above

15.Which of the following are valid "include" formats?
A)#include and #include[file.h]
B)#include (file.h) and #include
C)#include [file.h] and #include "file.h"
D)#include and #include "file.h"


Title: More C/C++ Questions
Post by: Khushi on October 13, 2006, 12:58:54 AM
To see more FAQ see this link of Steve Summit.. he has written a Book C Programming FAQ....

http://www.eskimo.com/~scs/C-faq/faq.html

Most Extensive list of Frequently Asked Question