You are on page 1of 13

Status: RO

//
1)
Consider the following program
#include <stdio.h>
void main()
{
int y,z;
int x=y=z=10;
int f=x;
float ans=0.0;
f=x*y;
ans=x/3.0 + y/3;
printf("%d,%.2f",f,ans);
}
/*

What will be the output of this program ?


a)
It will print 1000,6.66;
b)
It will give a type mismatch error;
c)
It will generate a compile-time error;
d)
None of the above;

*/
//
2)
Study the following code carefully
#include <stdio.h>
void main(void);
double dbl=20.4530,d=4.5710,dblvar3;
void main()
{
double dbfn(void);
dblvar3=dbfn();
printf("%.2f\t%.2f\t%.2f\n",dbl,d,dblvar3);
}
double dbfn(void)
{
double d,dblvar3;
dbl=d=dblvar3=4.5;
return(dbl+d+dblvar3);
}
/*

The output of the above


a)
4.50
4.57
b)
4.50
4.57
c)
4.57
4.57
d)
4.57
4.50

program will be
29.52;
13.50;
29.52;
13.50; */

//
3)
Consdier the following program
#include <stdio.h>
int SumElement(int *,int);
void main(void)
{
int x[10];
int i=10;
for(;i;)
{
i--;
*(x+i)=i;

}
printf("%d",SumElement(x,10));
}
int SumElement(int array[],int size)
{
int i=0;
float sum=0;
for(;i<size;i++)
sum+=array[i];
return sum;
}
/*

What will be the output of this program ?


a) It will print 45;
b) It will produce a type mismatch error as SumElement's return
statement returns a float;
c) It will produce a compilation error in statement for(;,i,;);
d) Both (b) and (c); */

// 4) Carefully study the following


#include <stdio.h>
void main(void)
{
int oldvar=25, newvar=-25;
int swap(int,int);
swap(oldvar,newvar);
printf("Numbers are %d \t %d",newvar,oldvar);
}
int swap(int oldval,int newval)
{
int tempval= oldval;
oldval = newval;
newval = tempval;
}
/*

The output of this program will be


a) Numbers are 25 -25
b)
Numbers are 25 25
c) Numbers are -25 25
d)
Numbers are -25 -25 */

// 5) Consider the following program


#include <stdio.h>
void main(void);
int newval(int);
void main(void)
{
int ia[]={12,24,45,0};
int i,sum=0;
for(i=0;ia[i];i++)
{
sum+=newval(ia[i]);

}
printf("Sum = %d",sum);
}
int newval(int x)
{
static int div = 1;
return (x/div++);
}
/*

The output of this program will be


a) Sum = 61;
b)
Sum = 39;
c) Runtime error
d)
Compilation error */

// 6) Study the following program


#include <stdio.h>
void main(void);
void main(void)
{
int var1=5,var2=5,var3=6,minmax;
minmax = (var1 > var2) ? (var1 > var3) ? var1:var3:(var2 > var3) ? var2:
var3;
printf("%d\n",minmax);
}
/* This program will
a) Produce a runtime error
b) Produce a compilation error
c) Print 5
d) Print 6 */
// 7) Consider the following program
#include <stdio.h>
void main(void);
void main(void)
{
void pa(int *a,int n);
int arr[5]={5,4,3,2,1};
pa(arr,5);
}
void pa(int *a,int n)
{
int i;
for(i=0;i<n;i++)
printf("%d\n",*(a++)+i);
}
/* Which of the following is correct ?
a) The Program prints the alternate elements of array.
b) It will not compile as 'array' cannot be incremented.
c) It will print 6,5,4,3,2 on individual lines.
d) It will print 5 five times 6 */

// 8) Consider the program in two files.


// The content of the file1.c is
#include <stdio.h>
void main(void);
void print(void);
void main(void)
{
print();
}
void f1(void)
{
printf("\n f1();");
}
// and the content of the file2.c is
#include <stdio.h>
void print(void)
{
extern void f1(void);
f1();
}
static void f1(void)
{
printf("\n static f1();");
}
/* Which will be the output of the program ?
a) It will print f1().
b) It will print the value returned by f1().
c) It will produce a compile-time error as f1() is defined twice.
d) None of the above */
// 9) Read the following code
#include <stdio.h>
void main(void);
static int i=50;
int print(int i);
void main(void)
{
static int i=100;
while (print(i))
{
printf("%d\n",i);
i--;
}
}
int print(int x)
{
static int i = 2;
return(i--);
}
/* What will be the output of this program ?
a) It will print from 100 to 0 in steps of -1

b) It will print 100 and 99 on two steps


c) It will print 100,99 and 98 and stop
d) None of the above
*/
----------------// 10) Carefully study the given program
#include <stdio.h>
#include <alloc.h>
void main(void);
typedef struct NType
{
int i;
char c;
long x;
}NewType;
void main(void)
{
NewType *c;
c=(NewType*)malloc(sizeof(NewType));
c->i=100;
c->c='C';
(*c).x=100l;
printf("%d,%c,%4ld",c->i,c->c,c->x);
}
/*
a)
b)
c)
d)
*/

What is the output of this program ?


It will produce a variable redefinition error
It will print some junk
It will print 100,C,100
It will print 100,C,l100

// 11) Carefully go through the following program


#include <stdio.h>
void main(void);
const int k=100;
void main(void)
{
int a[100];
int sum=0;
for(k=0;k<100;k++)
*(a+k)=k;
sum += a[--k];
printf("%d",sum);
}
/*
What will be the out put of this program ?

a)
b)
c)
d)
*/

It will
It will
It will
None of

print the sum of all the elements


print 99
produce a runtime error
the above

// 12) Read the following program carefully


#include <stdio.h>
void main(void);
int printf(const char*,...);
void main(void)
{
int i = 100,j=10,k=20;
int sum;
float ave;
char myformat[]="ave = %.2f";
sum=i+j+k;
ave=sum/3;
printf(myformat,ave);
}
/*
What will the above program do ?
a) It will print 43.33
b) It will print 43.34
c) It will produce a compilation error
d) None of the above
*/
// 13) Consider the following program code
#include <stdio.h>
void main(void)
{
int a[10];
printf("%d",*(a/(a+9)));
}
/*
a)
b)
c)
d)

What will the program do ?


It will print some junk as array a is not initialised.
It will result in a compilation error.
It will produce a runtime error as array a is not initialised.
None of the above. */

// 14) Carefully go through the following code


#include <stdio.h>
void main(void);
void main(void)
{
struct s{
int x;
float y;
}s1 = {25,45.00};
union u{
int x;

float y;
}u1;
u1=(union u)s1;
printf("%d and %f",u1.x,u1.y);
}
/* What will this program point ?
a)
b)
c)
d)

25 and 45.00
Produce a compilation error
45 and 45.00
Produce a runtime error */

// 15) Consider the following C program.


#include <stdio.h>
void main(void)
{
unsigned int c;
unsigned x=0x0003;
scanf("%u",&c);
switch(c&x)
{
case 3 :
case 2 :
case 1 :
default:

printf("Hello! \t");
printf("Welcome \t");
printf("To All \t");
printf("\n");

}
}
/* If the value input for the variable c is 10, what will be the output
of the program ?
a) The program will generate a compile time error as there is no break
statement for the various case choices.
b) The program will print Hello!
c) The program will print Welcome
To All
d) None of the above */
// 16)
#include <stdio.h>
// print the sum of series 1/5 + 1/4 + ...
static int i=5;
void main(void)
{
int sum = 0;
do
{
sum+=(1/i);
}while (0 < i--);
}
/*
a)
b)
c)

What will this program output ?


It will point the sum of the series 1/5 + 1/4 + ... + 1/1
It will produce a compilation error
It will produce a runtime error

d) None of the above


*/
// 17)
#include <stdio.h>
void main(void);
void main(void)
{
int i = 100,j=20;
i++=j;
i*=j;
printf("%d\t%d\n",i,j);
}
/*
a)
b)
c)
d)
*/

What will this program output ?


It will print 400 20
It will produce a compilation error
It will print 401 21
It will print some garbage

// 18) What will the following program do ?


#include <stdio.h>
int fn(void);
void print(int,int(*)());
int i = 10;
void main(void)
{
int i = 20;
print(i,fn);
}
void print(int i,int (*fn1)())
{
printf("%d\n",(*fn1)());
}
int fn(void)
{
return(i-=5);
}
/*
a) There will be a compilation error.
b) It will print 5
c) There will be a linkage error as there is no fn1() function definition
d) both (a) and (c).
*/
From krishv Thu Aug 21 18:19 IST 1997
Return-Path: <krishv>
Received: from deodar by bronto.iitm.ernet.in (5.0/SMI-4.0)
id AA20663; Thu, 21 Aug 1997 18:19:51 --5-30
Received: by deodar id <AA01469@deodar>; Thu, 21 Aug 97 18:19:24 IST
From: krishv (Radhakrishnan (Dr.(Mrs).KK))

Date: Thu, 21 Aug 97 18:19:24 IST


Message-Id: <9708211249.AA01469@deodar>
To: mani@bronto.iitm.ernet.in
Subject: Wipinf
Content-Type: text
Content-Length: 3299
Status: OR

Hi
These are some of the questions asked in the Wip.Info. test.
Written : Mainly OS, Datastructures, C and CO .
Answers : All the answers which iam giving here may not right. These are
just what I wrote there.
1. On Deadlock : Trivial
2. CPU Utilization:
given
CPU time
paging
I/O

answer, Shared Data


: 20 %
: 97.7%
: 5.33 %

Which of the following is not likely to improve CPU Utilization:


Ans: Installing a faster CPU
3. Bubble sort : Given sequence of numbers what will be order of sequences
after two iterations.
Ans: very trivial, but you should know what bubble sort
does.
4. Bubble sort : how many swap operations has been done in the above
process?
5. What data structures you should use for dictionary searching and it
should be capable of doing spell check also ?
Ans: Hashing
6. Which is the best scheduling algo. (given five of them)
Ans.: Shortest Job First with Pre-emption
7. If a numbering system uses 0 , 1 and Z where Z stands for -1
what is the value of 6.25 :
Z01 = 1*1 + 0*2 + (-1)*4
Ans: You can easily find out by trial and error keep in mind
that other side of dot will proceed as 1/2, 1/4 ...
8. What is the value of 121 base 4 + 84 base 16 ?
Ans : 2130
9. What Aliases stands for ...........?
10.What is the value of
ABCD + AB'C'D' + AB'C'D + AB'C'D' ?
( Expression may not be the exact one but something similar to
the above )

11. & 12. Given a C code. What is the OUtput ?


Ans: Trivial, just we have to go through the code
carefully.
ONe of the questions is to reverse the given number.
ie. given 3276 the pgm. will output 6723
13. ONe questions on CO, which is slight a lenghty one and I couldnt'
recollect the same.
14. Given Three trees and ONe sequence of alphabets, we are suppose
to find which operation was performed on the tress to get
that result. ie. either preorder, postorder or inorder.
Ans: To that question, all preorder
15. When the fn. is called where the return add. is stored?
ans. stack
16. What is the nece. for compiler to support recursion?
ans/ stack
There are five more questions which i could not recollect as of
now and mail you later.
bye
krishv

Questions that are asked to me in the wip.info. interview.


1. What are the funs. of transport layer? What is TCP, UDP, their
differences .....
2. If you undelete a file in unix or dos can you recover it?
If you can how will you do it?
3. Write a pgm. to check whether given string is palindrome or not?
4. Which page replacement algo. is the best one? ie. the one which
will give less page faults, assuming cache memory is not there.
4. Do you know unix internals?
5. What is TSR ? Explain in little detail? HOw it is handled?
6. How to fine the size of the int without using size of operator?
ans. store -1 in that location so by two's complement all ones
will be stored in that location. Keep right shifting it
so zeros will be appened on the left. Once the location
is filled with all zeros, the number of shifts gives you
the size of that operator.
7. About ARP and RARP.
8. HOw parameter passing in C
9. What compiler actually does
Some more personal questions.

Status: OR

Hi
These are some of the questions asked in the Wip.Info. test.
Written : Mainly OS, Datastructures, C and CO .
Answers : All the answers which iam giving here may not right. These are
just what I wrote there.
1. On Deadlock : Trivial
2. CPU Utilization:
given
CPU time
paging
I/O

answer, Shared Data


: 20 %
: 97.7%
: 5.33 %

Which of the following is not likely to improve CPU Utilization:


Ans: Installing a faster CPU
3. Bubble sort : Given sequence of numbers what will be order of sequences
after two iterations.
Ans: very trivial, but you should know what bubble sort
does.
4. Bubble sort : how many swap operations has been done in the above
process?
5. What data structures you should use for dictionary searching and it
should be capable of doing spell check also ?
Ans: Hashing
6. Which is the best scheduling algo. (given five of them)
Ans.: Shortest Job First with Pre-emption
7. If a numbering system uses 0 , 1 and Z where Z stands for -1
what is the value of 6.25 :
Z01 = 1*1 + 0*2 + (-1)*4
Ans: You can easily find out by trial and error keep in mind
that other side of dot will proceed as 1/2, 1/4 ...
8. What is the value of 121 base 4 + 84 base 16 ?
Ans : 2130
9. What Aliases stands for ...........?
10.What is the value of
ABCD + AB'C'D' + AB'C'D + AB'C'D' ?
( Expression may not be the exact one but something similar to
the above )
11. & 12. Given a C code. What is the OUtput ?

Ans: Trivial, just we have to go through the code


carefully.
ONe of the questions is to reverse the given number.
ie. given 3276 the pgm. will output 6723
13. ONe questions on CO, which is slight a lenghty one and I couldnt'
recollect the same.
14. Given Three trees and ONe sequence of alphabets, we are suppose
to find which operation was performed on the tress to get
that result. ie. either preorder, postorder or inorder.
Ans: To that question, all preorder
15. When the fn. is called where the return add. is stored?
ans. stack
16. What is the nece. for compiler to support recursion?
ans/ stack
There are five more questions which i could not recollect as of
now and mail you later.
bye
krishv

Questions that are asked to me in the wip.info. interview.


1. What are the funs. of transport layer? What is TCP, UDP, their
differences .....
2. If you undelete a file in unix or dos can you recover it?
If you can how will you do it?
3. Write a pgm. to check whether given string is palindrome or not?
4. Which page replacement algo. is the best one? ie. the one which
will give less page faults, assuming cache memory is not there.
4. Do you know unix internals?
5. What is TSR ? Explain in little detail? HOw it is handled?
6. How to fine the size of the int without using size of operator?
ans. store -1 in that location so by two's complement all ones
will be stored in that location. Keep right shifting it
so zeros will be appened on the left. Once the location
is filled with all zeros, the number of shifts gives you
the size of that operator.
7. About ARP and RARP.
8. HOw parameter passing in C
9. What compiler actually does
Some more personal questions.

You might also like