C:
1.what is the o/p ?
void main()
{
char *mess[]={"Have","a","nice","day","Bye");
printf("%d \t %d",sizeof(mess),sizeof(mess[1]));
}
a. 16 4
b. 5 4
c. 20 4
d. Error
answer: c
2.what is the o/p of the following programe?
void main()
{
int i,count=0;
char *p1="abcdefghij";
char *p2="alcmenfoip";
for(i=0;i<=strlen(p1);i++) {
if(*p1++ == *p2++)
count+=5;
else
count-=3;
}
printf("count=%d\n",count);
}
a. 15
b. 6
c. 12
d. compiler error
answer: b ( note : strlen(p1) == i when i=6)
3.what does main return on successful execution?
a. 1
b. 0
c. -1
d.Nonzero
answer:b
4.
main(int argc,char *argv[])
{
printf((argc > 1 ? "%c" : "%c",*++argv);
}
If the i/p string is "GESL Bangalore".
a. G
b. E
c. B
d. GESL
answer: c
5. How do u declare a pointer to an array of pointers to int?
a. int *a[5];
b. int **a[5];
c. int *(*a)[5];
d. u con not declare
answer: c
Questions on OS:
1.UDP is a
a. Reliable protocol
b. Unreliable protocol
c. Connectionless protocol
d. Both b & c
Answer: d
2.Real Time OS uses
a. RISC processor
b. CISC processor
c. SISC processor
d. Any of the above
Answer: a
3.Race condition could be overcome using
a. A global variable
b. A local variable
c. Mutex
d. All of the above
4.Repeaters are in
a. Data link layer
b. Physical layer
c. Network layer
d. Transport layer
Answer: b
5.Telecom Networking uses
a. Packet switching
b. Circuit switching
c. Message switching
d. Non of the above
Ans : b ( normally )
( packet switching in ISDN )
---------------------------------------------------------------------
1) main(){
int a;
char *p;
a = sizeof(int) * p;
printf("%d\n",a);
}
a)compile error
b)run time error
c)4
d)compiler dependent
ans:a
2)#define SIZE sizeof(int)
main(){ int i=-1;
if( i < SIZE )
printf("True\n");
else
printf("False\n");
}
a) True
b) False
c) can't predict
d) None of these
ans:b (?)
3) int (*fun())[]
a) function returning a pointer to an array
b) function returning an array of pointers
c) pointer to a funtion which takes array as asrument
d) Compiler error
ans: a
4) main(){
int a=8,d;
int *p;
p=&a;
d=a/*p;
print("%d\n",d);
}
a) 1
b) 0
c) compiler error
d) run time error
ans: c
5)main(){
char *a="Hello";
*a++ = 'h';
printf("%s\n",a);
}
a) hello
b) ello
c) runtime error
d) compiler error
ans:b
6) main(){
char p[]="Hello";
p[0]='h';
printf("%s\n", p);
}
a) hello
b) Hello
c) compiler error
d) run time error
ans:a
7)#define mysizeof(a) (&a+1) - &a
main(
float d;
printf("%d\n", mysizeof(d) );
}
note: assume sizeof float is 8 bytes
a) 8
b) 4
c) 1
d) compiler error
ans:c
8) main()
{ int *p=10;
printf("%d\n",*p);
}
a) 10
b) run time error
c) compiler error
d) 5
ans:b (?)
9)main(){
int i=-1;
i<<=2;
printf("%d\n",i);
}
a) -1
b) -2
c) -4
d) 0
ans:c
10) main(){
int i= 0xffffffff;
printf("%d\n",i);
}
note: size of int is 4 bytes
a) -1
b) 65635
c) 100
d) error
ans:a
--------------------------------------------------------------------
C/C++ Questions
- What is the output of printf("%d")
- What will happen if I say delete this
- 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?.
- 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?
- What is "strstream" ?
- Explain "passing by value", "passing by pointer" and "passing by reference"
- Have you heard of "mutable" keyword?
- What is a "RTTI"?
- Is there something that I can do in C and not in C++?
- 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"?
- Difference between "printf" and "sprintf
- What is "map" in STL?
- When shall I use Multiple Inheritance?
- Explain working of printf.
- Talk sometiming about profiling?
- How many lines of code you have written for a single program?
- How to write Multithreaded applications using C++?
- Write any small program that will compile in "C" but not in "C++"
- What is Memory Alignment?
- Why preincrement operator is faster than postincrement?
- What are the techniques you use for debugging?
- How to reduce a final size of executable?
- Give 2 examples of a code optimization--------------------------------------------------------------------------------------
Operating system:
- What is MUTEX ?
- What isthe difference between a 'thread' and a 'process'?
- What is INODE?
- Explain the working of Virtual Memory.
- How does Windows NT supports Multitasking?
- Explain the Unix Kernel.
- What is Concurrency? Expain with example Deadlock and Starvation.
- What are your solution strategies for "Dining Philosophers Problem" ?
- Explain Memory Partitioning, Paging, Segmentation.
- Explain Scheduling.
- Operating System Security.
- What is Semaphore?
- Explain the following file systems : NTFS, Macintosh(HPFS), FAT .
- What are the different process states?
- What is Marshalling?
- Define and explain COM?
- What is Marshalling?
- Difference - Loading and Linking ?
MAX-MARKS-25
DURATION- 45min
1)main()
{
int *a, *s, i;
s = a = (int *) malloc( 4 * sizeof(int));
for (i=0; i<4; i++)
*(a+i) = i * 10;
printf("%d\n", *s++);
printf("%d\n", (*s)++);
printf("%d\n", *s);
printf("%d\n", *++s);
printf("%d\n", ++*s);
}
Ans: 0 10 11 20 21
2) What would be the output of the following program.
main() {
int a[3]={2,3,4};
char *p;
p=a;
p=(char *)((int *)p+1);
printf("%d",p); }
(a) 2 (b) 0 (c) junk value (d) 3
3) The return type of “ malloc() “ is
a. Void *
b. Depends on the type of data which is being allocated.
c. Void
d. None of these
4)Give the output:
int main(){
unsigned int i=1,j;
for(j=0;j<4;j++)
i=i<<j;
printf(" %d ",i);
}
Ans:64 5) .What would be the output of the following program.
main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e = {"tiger"};
printf("\n %d %f",e.age,e.sal);
}
(a) 0 0.000000 (b) Garbage values (c) Error (d) none of the above
6) What will the printf print?
main()
{
char *p,*f();
p=f();
printf("f() returns:%s\n",p);
}
char *f()
{
char result[80];
strcpy(result,"anything will do");
return (result);
}
(a) f() returns: anything will do (b) f() returns:
(c) compilation error (d) The printf statement is not going to be executed
7) What would be the output of the following program.
main()
{
int a,b;
a=sumdig(123);
b=sumdig(123);
printf("%d %d",a,b);
}
sumdig(int n)
{
static int s=0;
int d;
if(n!=0)
{
d=n%10;
n=(n-d)/10;
s=s+d;
sumdig(n);
}
else return(s);
}
(a) 12 6 (b) 6 12 (c) 3 15 (d) error
8) What would be the output?
main(int argc, char *argv[])
{
while(sizeofargv)
printf("%s",argv[--sizeofargv]);
}
a) myprog friday tuesday sunday b) myprog friday tuesday
c) sunday tuesday friday myprog d) sunday tuesday Friday
9) . What would be the output of the following program?
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
a) 1 1 1 b) 1 2 4 c) 2 4 4 d) 4 4 4
9) . What would be the output of the following program?
main()
{
int y=128;
const int x=y;
printf("%d",x);
}
a) 128 b) Garbage value c) Error d) 0
10) In the following code, in which order the functions would be called?
a= f1(23,14)*f2(12/4)+f3();
a) f1, f2, f3 b) f3, f2, f1
c) The order may vary from compiler to compiler d) None of the above
11) . # define prod(a,b) a*b
main()
{
int x=2;
int y=3;
printf("%d",prod(x+2,y-10));
}
the output of the program is
(a) 8 (b) 6 (c) 7 (d) None
12) Consider the following program
main()
{
int a[5]={1,3,6,7,0};
int *b;
b=&a[2];
}
The value of b[-1] is
(a) 1 (b) 3 (c) -6 (d) none
13) Pick out the odd one out
(a) malloc() (b) calloc() (c) free() (d) realloc()
14) . Given the piece of code
int a[50];
int *pa;
pa=a;
To access the 6th element of the array which of the following is incorrect?
(a) *(a+5) (b) a[5] (c) pa[5] (d) *(*pa + 5}
15) What would be the output of the following program.
main()
{
int a[5]={2,3};
printf("\n %d %d %d",a[2],a[3],a[4]);
}
(a) garbage value (b) 2 3 3 (c) 3 2 2 (d) 0 0 0
16) . Find the output for the following C program
int i =10
main(){
int i =20,n;
for(n=0;n<=i;)
{int i=10;
i++;
}
printf("%d", i);
a)20 b)10 c)11 d)21
17) What does the following program print?
void main(void)
{
int i;
static int k;
if(k=='0')
printf("one");
else if(k== 48)
printf("two");
else
printf("three");
}
a. prints one b. prints two c. prints three d. prints one three
18)which of the following statement is correct?
a. sizeof('*') is equal to sizeof(int) b. sizeof('*') is equal to sizeof(char)
c. sizeof('*') is equal to sizeof(double) d. none
19) main(){
int i;
for (i=7;i<=0;i--)
printf ("hello\n");}
what is the output
a) prints hello 7 times
b) prints hello 8 times
c) prints hello once
d) prints nothing
20) main(){
printf( printf ("world") );}
a) prints world
b) prints printf ("world")
c) prints nothing
d) compiler error
21) . 14
/ \
2 11
/ \ / \
1 3 10 30
/ /
7 40
For the above tree which statement is correct ?
A. The tree is not a complete binary tree.
B. The tree is a complete binary tree.
C. The tree is a strictly binary tree.
D. None of the above.
22) The five iterms A,B,C,D and E are pushed in a stack, one after the other starting from A. The stack is popped four times and each element in inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack . The popped item is
a. A b. B c. C d. D
23) Recursive procedures are implemented by
a. Queue b. Stacks. c. Linked lists. d. Strings.
24) The infix expression (A+(B-C)*D) is correctly represented in prefix notation as
a. A+B-C*D
b. +A*-BCD
c. ABC-D*+
e.A+BC-D*
25) . What is the time complexity of linear search algorithm over an array of n elements?
a. O (log2 n)
b. O (n) (ans)
c. O (n log2 n)
d. O (n2)