Friday, July 25, 2008

Obejctive Questions on C

1. What is the output of the program given below
#include
main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}
3. What is the memory allocated by the following definition ?
int (*x)[10];
4. What is the memory allocated by the following definition ?
int (*x)();
5. In the following program segment
#include
main()
{
int a=2;
int b=9;
int c=1;
while(b)
{
if(odd(b))
c=c*a;
a=a*a;
b=b/2;
}
printf("%d\n",c);
}
How many times is c=c*a calculated?
6. In the program segment in question 5 what is the value of a at the end of the
while loop?
7. What is the output for the program given below
typedef enum grade{GOOD,BAD,WORST,}BAD;
main()
{
BAD g1;
g1=1;
printf("%d",g1);
}

8. Give the output for the following program.
#define STYLE1 char
main()
{
typedef char STYLE2;
STYLE1 x;
STYLE2 y;
clrscr();
x=255;
y=255;
printf("%d %d\n",x,y);
}
9. Give the output for the following program segment.
#ifdef TRUE
int I=0;
#endif
main()
{
int j=0;
printf("%d %d\n",i,j);
}
10.What is the output for the following program
#include
main()
{
char a[5][5],flag;
a[0][0]='A';
flag=((a==*a)&&(*a==a[0]));
printf("%d\n",flag);
}
11. In the following program
#include
main()
{
char *pDestn,*pSource="I Love You Daddy";
pDestn=malloc(strlen(pSource));
strcpy(pDestn,pSource);
printf("%s",pDestn);
free(pDestn);
}
(a)Free() fails
(b)Strcpy() fails
(c)prints I love You Daddy
(d)error
C programs are asked in this section
12.Write a program to insert a node in a sorted linked list.
13.Write a program to implement the Fibonacci series.
14.Write a program to concatenate two circular linked lists into a single circular list.
15.A function even_odd_difference()passes the array of elements.Write a program to calculate the difference of the two sums of which one sum adds the elements of odd ones and another adds the elments of even ones.
16.Write a program to reverse a linked list.

17.Base class has some virtual method and derived
class has a method with the same name. If we initialize the base class pointer with derived object,. calling of that virtual method will result in which method being called? a. Base method
b. Derived method..
Ans. b
Almost all questions are of this kind. Go through virtual functions concepts in C++ and how the pointers to functions would be handled
18. Write the program/algorithm or pseudo code to do following operation
given matrix
Input Matrix
1 2 3
4 5 6
7 8 9
Output Matrix
9 8 7
6 5 4
3 2 1
the algo or program should be able to do this.
19. Hotel owner to teacher: you know that mohan came here with 3 girl friends. if multiply their ages the result will be 2450. and the sum of their ages is equal to u'r age. the eldest girl is elder than mohan can u tell me mohan's age.

20. one more question
answer approach is
2+3+.....127
ans: 137 (Pls. verify)
21. one more question about 4 ships
do it well there are 7 conditions and 7th condition will not be satisfied.dont go for that consider the first 6 conditions
Instructions:
 First do the program part and write down the assumptions u made.
 Be careful with your interest : suppose if you say reading news paper you should be knowing the current news.
 and good communication skills is a must.
 dont write any thing that you don't know in resume.
 no problem if you say you don't know c. because they will give you training.
 pay package is 2.04 lakhs.
22.void main()
{
extern int a;
a=10;
printf("%d",a);
}
will
1. give linker error- a not defined ans
2. print 10
3. give compiler error
23.int a[10];
printf("%d,%d",a[0],a[12]);
will compiler show any error?
ans no

Write the programs for the following problems in C.
1. Swap two variables x,y without using a temporary variable.
2. Write algorithm for finding the GCD of a number.
3.Write a program for reversing the given string.
4. The integers from 1 to n are stored in an array in a random
fashion. but one integer is missing. Write a program to find the
missing integer.
Ans). Hint : The sum of n natural numbers is = n(n+1)/2.
if we subtract the above sum from the sum of all the
numbers in the array , the result is nothing but the
missing number.

5. Some bit type of questions has been given on pointers asking to
to find whether it is correct from syntax point of view. and if
it is correct explain what it will do. (around 15 bits).
6. For the following C program
#define AND &&
#define ARRANGE (a>25 AND a<50)
main()
{int a = 30;
if (ARRANGE)
printf("within range");
else
printf("out of range");
}
What is the output?
7. For the following C program
#define AREA(x)(3.14*x*x)
main()
{float r1=6.25,r2=2.5,a;
a=AREA(r1);
printf("\n Area of the circle is %f", a);
a=AREA(r2);
printf("\n Area of the circle is %f", a);
}
What is the output?
Ans. Area of the circle is 122.656250
Area of the circle is 19.625000
8. What do the following statements indicate. Explain.
 int(*p)[10]
 int*f()
 int(*pf)()
 int*p[10]
Refer to:
-- Kernighan & Ritchie page no. 122
-- Schaum series page no. 323
9. Write a C program to find whether a stack is progressing in forward
or reverse direction.
10. Write a C program that reverses the linked list.
1.
void main()
{
int d=5;
printf("%f",d);
}
Ans: Undefined
2.
void main()
{
int i;
for(i=1;i<4,i++)
switch(i)
case 1: printf("%d",i);break;
{
case 2:printf("%d",i);break;
case 3:printf("%d",i);break;
}
switch(i) case 4:printf("%d",i);
}
Ans: 1,2,3,4
3.
void main()
{
char *s="\12345s\n";
printf("%d",sizeof(s));
}Ans: 6

4.
void main()
{
unsigned i=1; /* unsigned char k= -1 => k=255; */
signed j=-1; /* char k= -1 => k=65535 */
/* unsigned or signed int k= -1 =>k=65535 */
if(iprintf("less");
else
if(i>j)
printf("greater");
else
if(i==j)
printf("equal");
}
Ans: less
5.
void main()
{
float j;
j=1000*1000;
printf("%f",j);
}

1. 1000000
2. Overflow
3. Error
4. None
Ans: 4
6. How do you declare an array of N pointers to functions returning
pointers to functions returning pointers to characters?

Ans: The first part of this question can be answered in at least
three ways:

1. char *(*(*a[N])())();

2. Build the declaration up incrementally, using typedefs:

typedef char *pc; /* pointer to char */
typedef pc fpc(); /* function returning pointer to char */
typedef fpc *pfpc; /* pointer to above */
typedef pfpc fpfpc(); /* function returning... */
typedef fpfpc *pfpfpc; /* pointer to... */
pfpfpc a[N]; /* array of... */

3. Use the cdecl program, which turns English into C and vice
versa:

cdecl> declare a as array of pointer to function returning
pointer to function returning pointer to char
char *(*(*a[])())()

cdecl can also explain complicated declarations, help with
casts, and indicate which set of parentheses the arguments
go in (for complicated function definitions, like the one
above).
Any good book on C should explain how to read these complicated
C declarations "inside out" to understand them ("declaration
mimics use").
The pointer-to-function declarations in the examples above have
not included parameter type information. When the parameters
have complicated types, declarations can *really* get messy.
(Modern versions of cdecl can help here, too.)


7. A structure pointer is defined of the type time . With 3 fields min,sec hours having pointers to intergers.
Write the way to initialize the 2nd element to 10.

8. In the above question an array of pointers is declared.
Write the statement to initialize the 3rd element of the 2 element to 10;
9.
int f()
void main()
{
f(1);
f(1,2);
f(1,2,3);
}
f(int i,int j,int k)
{
printf("%d %d %d",i,j,k);
}

What are the number of syntax errors in the above?

Ans: None.
10.
void main()
{
int i=7;
printf("%d",i++*i++);
}

Ans: 56

11.
#define one 0
#ifdef one
printf("one is defined ");
#ifndef one
printf("one is not defined ");

Ans: "one is defined"
12.
void main()
{
int count=10,*temp,sum=0;
temp=&count;
*temp=20;
temp=∑
*temp=count;
printf("%d %d %d ",count,*temp,sum);
}
Ans: 20 20 20
13. There was question in c working only on unix machine with pattern matching.
14. what is alloca()
Ans : It allocates and frees memory after use/after getting out of scope
15.
main()
{
static i=3;
printf("%d",i--);
return i>0 ? main():0;
}
Ans: 321
16.
char *foo()
{
char result[100]);
strcpy(result,"anything is good");
return(result);
}
void main()
{
char *j;
j=foo()
printf("%s",j);
}
Ans: anything is good.
17.
void main()
{
char *s[]={ "dharma","hewlett-packard","siemens","ibm"};
char **p;
p=s;
printf("%s",++*p);
printf("%s",*p++);
printf("%s",++*p);
}
Ans: "harma" (p->add(dharma) && (*p)->harma)
"harma" (after printing, p->add(hewlett-packard) &&(*p)->harma)
"ewlett-packard
1. What is the mistake in the following program segment ?
f()
{
int a;
void c;
f2(&c,&a);}
2. a=0;
b=(a=0)?2:3;

a) What will be the value of b and why ?
b) If in first statement a=0 is replaced by a = -1, b= ?
c) If in second statement a=0 is replaced by a = -1, b=?
3. char *a[2];
int const *p;
int *const p;
struct new { int a;int b; *var[5] (struct new)}

Describe the statements in the above given construct ?
4. f()
{
int a=2;
f1(a++);
}
f1(int c)
{
printf("%d", c);
}
What is the value of c ?
5. f1()
{
f(3);
}
f(int t)
{
switch(t);
{
case 2: c=3;
case 3: c=4;
case 4: c=5;
case 5: c=6;
default: c=0;
}
What is the value of c?
6. What is the fallacy in the following program segment ?
int *f1()
{
int a=5;
return &a;
}
f()
int *b=f1()
int c=*b;
}
7. Give the C language equivalents of the following
a)Function returning an int pointer
b)Function pointer returning an int pointer
c)Function pointer returning an array of integers
d)Array of function pointer returning an array of integers
8. Find the fallacy in the following program segment?
int a;
short b;
b=a;

9. Define function ? Explain arguments in functions ?

10. How does C pass variables to a function ?
11. Explain the following program segment.
f(){
int *b;
*b=2;
}


12. Explain binary trees and their use ?
13. Draw the diagram showing the function stack, illustrating the variables that were pushed on the stack at the point when function f2 has been introduced .
type def struct
{ double x,double y} point; }
main( int argc, char *arg[3])
{ double a;
int b,c;
f1(a,b); }
f1(double x, int y)
{point p;
stack int n;
f2(p,x,y)
}
f2(point p, double angle)
{ int i,j,k,int max;
}

16. In UNIX a files i-node ......?
Ans. Is a data structure that defines all specifications of a file like the file size,
number of lines to a file, permissions etc.

17. The UNIX shell ....
a) does not come with the rest of the system
b) forms the interface between the user and the kernal
c) does not give any scope for programming
d) deos not allow calling one program from with in another
e) all of the above
Ans. (b)

18. enum number { a=-1, b= 4,c,d,e}
What is the value of e ?
(a) 7
(b) 4
(c) 5
(d) 15
(e) 3

19. The very first process created by the kernal that runs till the kernal process is halts is
a) init
b) getty
c) both (a) and (b)
d) none of these
Ans. (a)

20. Output of the following program is
main()
{int i=0;
for(i=0;i<20;i++)
{switch(i)
case 0:i+=5;
case 1:i+=2;
case 5:i+=5;
default i+=4;
break;}
printf("%d,",i);
}
}
a) 0,5,9,13,17
b) 5,9,13,17
c) 12,17,22
d) 16,21
e) Syntax error
Ans. (d)

21. What is the ouptut in the following program
main()
{char c=-64;
int i=-32
unsigned int u =-16;
if(c>i)
{printf("pass1,");
if(cprintf("pass2");
else
printf("Fail2");
}
else
printf("Fail1);
if(iprintf("pass2");
else
printf("Fail2")
}
a) Pass1,Pass2
b) Pass1,Fail2
c) Fail1,Pass2
d) Fail1,Fail2
e) None of these
Ans. (c)

22. In the process table entry for the kernel process, the process id value is
(a) 0
(b) 1
(c) 2
(d) 255
(e) it does not have a process table entry
Ans. (a)

23. Which of the following API is used to hide a window
a) ShowWindow
b) EnableWindow
c) MoveWindow
d) SetWindowPlacement
e) None of the above
Ans. (a)

24. What will the following program do?
void main()
{
int i;
char a[]="String";
char *p="New Sring";
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p); //Line number:9//
p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf("(%s, %s)",a,p);
free(p);
free(a);
} //Line number 15//
a) Swap contents of p & a and print:(New string, string)
b) Generate compilation error in line number 8
c) Generate compilation error in line number 5
d) Generate compilation error in line number 7
e) Generate compilation error in line number 1
Ans. (b)

25. In the following code segment what will be the result of the function,
value of x , value of y
{unsigned int x=-1;
int y;
y = ~0;
if(x == y)
printf("same");
else
printf("not same");
}
a) same, MAXINT, -1
b) not same, MAXINT, -MAXINT
c) same , MAXUNIT, -1
d) same, MAXUNIT, MAXUNIT
e) not same, MAXINT, MAXUNIT
Ans. (a)

26. PATH = /bin : /usr : /yourhome
The file /bin/calender has the following line in it
cal 10 1997
The file /yourhome/calender has the following line in it
cal 5 1997
If the current directory is /yourhome and calender is executed
a) The calendar for May 1997 will be printed on screen
b) The calendar for Oct 1997 will be printed on screen
c) The calendar for the current month( whatever it is) will be printed
d) Nothing will get printed on screen
e) An error massage will be printed

27. What will be the result of the following program ?
char *gxxx()
{static char xxx[1024];
return xxx;
}
main()
{char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is : %s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
Ans. (b)

28. What will be result of the following program?
void myalloc(char *x, int n)
{x= (char *)malloc(n*sizeof(char));
memset(x,\0,n*sizeof(char));
}
main()
{char *g="String";
myalloc(g,20);
strcpy(g,"Oldstring");
printf("The string is %s",g);
}
a) The string is : String
b) Run time error/Core dump
c) The string is : Oldstring
d) Syntax error during compilation
e) None of these

29. Which of the following function is used to repaint a window immediately
a) Sendmessage(hWnd,WM_PAINt,......)
b) InvalidateRect(.......)
c) MoveWindow
d) WM_COPY
e) None

30. Which function is the entry point for a DLL in MS Windows 3.1
a) Main
b) Winmain
c) Dllmain
d) Libmain
e) None
Ans. (b)

31. The standard source for standard input, standard output and standard error is
a) the terminal
b) /dev/null
c) /usr/you/input, /usr/you/output/, /usr/you/error respectively
d) None
Ans. (a)

32. What will be the result of the following program?
main()
{char p[]="String";
int x=0;
if(p=="String")
{printf("Pass 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
else
{
printf("Fail 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
}
a) Pass 1, Pass 2
b) Fail 1, Fail 2
c) Pass 1, Fail 2
d) Fail 1, Pass 2
e) syntax error during compilation

33. Which of the choices is true for the mentioned declaration ?
const char *p;
and
char * const p;
a) You can't change the character in both
b) First : You can't change the characterr & Second : You can;t change the pointer
c) You can't change the pointer in both
d) First : You can't change the pointer & Second : You can't chanage the character
e) None

34. The redirection operators > and >>
a) do the same function
b) differ : > overwrites, while >> appends
c) differ : > is used for input while >> is used for output
d) differ : > write to any file while >> write only to standard output
e) None of these
Ans. (b)

35. The command grep first second third /usr/you/myfile
a) prints lines containing the words first, second or third from the file /usr/you/myfile
b) searches for lines containing the pattern first in the files
second, third, and /usr/you/myfile and prints them
c) searches the files /usr/you/myfiel and third for lines containing the words first or second and prints them
d) replaces the word first with the word second in the files third and /usr/you/myfile
e) None of the above
Ans. (b)


Q9). what will be the result of executing following program
main
{
char *x="new";
char *y="dictonary";
char *t;
void swap (char * , char *);
swap (x,y);
printf("(%s, %s)",x,y);

char *t;
t=x;

x=y;
y=t;
printf("-(%s, %s)",x,y);
}
void swap (char *x,char *y)
{
char *t;
y=x;
x=y;
y=t;
}

a).(New,Dictionary)-(New,Dictionary)
b).(Dictionary,New)-(New,Dictionary)
c).(New,Dictionary)-(Dictionary,New)
d).(Dictionary,New)-(Dictionary,New)
e).None of the above

(Ans will be b or e) check

Q10).If a directory contains public files (can be valied and used
by any one ) which should not be altered ,the most liberal
permissions that can be given to the directory is
a)755
b)777
c)757
d)775
e)None of the above
(Ans a)
11) what would the following program results in

main()
{
char p[]="string";
char t;
int i,j;
for(i=0,j=strlen(p);i {
t=p[i];
p[i]=p[j-i];
p[j-i]=t;
}
printf("%s",p);
}
a)will print:string
b)will not print anything since p will be pointing to a null string
c)will print:gnirtS

d)will result in a complication error
e)will print invallid characters(junk)
(Ans will be b ) check
12) After the following command is executed
$ ln old new
a listing is performed with the following output
$ ls -li

total 3
15768 -rw-rw-rw- 2 you 29 Sep 27 12:07 old
15768 " " " " " " " " new
15274 " " 1 " 40 " " 09:34 veryold

which of the following is true

a)old and new have same i-node number,2
b) " " " " " " " , 15768
c)old and new have nothing yo do with each other
d)very old and new are linked

e)very old and old are linked
(Ans is b)
13) What will be the result of executing the following statement
int i=10;
printf("%d %d %d",i,++i,i++);
a).10 11 12
b).12 11 10
c).10 11 11
d).result is OS dependent
e).result is compiler dependent
(Ans is e)
14) What does extern means in a function declaration
a)the funct has global scope
b)the funct need not be defined\
c)nothing really
d)the funct has local scope only to the file it is defined in
e)none of the above
(Ans will be c)
15) What will be result of the following program
main()
{

void f(int,int);
int i=10;
f(i,i++);
}
void f(int i,int j)
{
if(i>50)
return;
i+=j;
f(i,j);
printf("%d,",i);
}
a).85,53,32,21
b)10,11,21,32,53
c)21,32,53,85
d)32,21,11,10
e)none of the above
(Ans is e)
16). MS windows 3.1 is a
a)operating system
b)Application
c)Programing language
d)database
e)shell
(Ans will be b)
17).MS Windows 3.1 supports which tyoe of multi-tasking?
a)cycle
b)executive
c)preemptive
d)Non-preemptive
e)Manual
(Ans )
18)The command ......ln/bin/mail /usr/you/bin/m
a)will not be executed because you are linking files
across different file systems
b)results ln /bin/main being the same file as /usr/you/bin/m
c)results in 2 links to the file mail
d) " " " " m
e)none
(Ans will be b)
19)In a standerd directory lay out ,/etc is the directory where
a) basic programs such as who and ed reside
b) device related files reside
c)various administrative files such as password file reside
d) short-lived files created during program execution reside
e) the C sub-routine library resides
(Ans is c)
20) The command echo *
a) echoes all files in the current directory
b) prints * on the screen
c) is an invalid command
d) is the same as the command echo\*
e) is the same as echo"*"
(Ans is a)
21)What will be the result of the following segment of the program
main()
{
char *s="hello world";
int i=7;
printf("%.*%s",s);
}
a)syntax error
b)hello w
c) Hello
d) o world
e) none
(Ans is b)
22) What will be the result of the following program
main()
{
int a,b;
printf("enter two numbers :");

scanf("%d%d",a,b);
printf("%d+%d=%d",a,b,a+b);
}
a) will print the sum of the numbers entered
b) syntax error during compilation
c) will generate run time error /core dump
d) will print the string "a+b = a+b" on the screen
e) none of these
(Ans is c)
23) What is the size of 'q'in the following program?
union{
int x;
char y;
struct {
char x;
char y;
int xy;}p;
}q;
a)11
b)6
c)4
d)5
e)none
(Ans is b why because no of bytes for int =4 given in instructions)
24) Which message is displayed when a window is destroyed
a)WM_CLOSE
b)WM_DESTROY
c)WM_NCDESTROY
d)WM_POSTDESTROY
E)NONE
(Ans is b)
25)Send Message and postmessage are
a)send message puts the message in the message queue and results,
postmessage processes the message immediately
b)Sendmessage processes the message immediately,postmessage puts
the message in the queue and returns
c) Both put the message in the message queue and returns
d) Both process the message immediately
e) None of the above
(Ans will be b check)
26) Which of the following message is used to limit the size
of teh Window
a)WM_SIZE
b)WM_PAIN
c) WM_GETMINMAXINFO
d) WM_COMMAND
e) WM_CREATE
(Ans is a)
27)until who|grep mary
do
sleep 60
done
a) is syntactically incorrect
b) waits 60 seconds irrespective of Mary being logged in or not
c) waits until Marry is logged in
d)waits till Mary exited
e)None
(Ans is c)
28)The UNIX system call that transforms an executable binary file into
a process is
a)execl()
b)execv()
c)execle()
d)execve()
e)All of the above
(Ans will be e check)
29)Which of the following is true about fork()
a) it transforms an executable binary file into a process that
overlays the

process which made the fork() system call.NO new process is created.
b) Causes the creation of a new process, the CHILD process, with a new
process ID
c)Causes the creation of a new process, the CHILD process ,with the
same
process ID as the parent
d)fork() has nothing to do with processes
e)fork() is not a system call
(Ans is b)
30) What do the following variable names represents?
sort register
volatile default
a) short - is not a reserved keyword
b ) volatile & register - is not a reserved keyword
c)all the above are keywords
d) all are valid variable names
e) default - is not a reserved keyword
(Ans is c)
31)What will be the result of the following program
main()
{
char *x="String";
char y[] = "add";
char *z;
z=(char *) malloc(sizeof(x)+sizeof(y)=1);
strcpy(z,y);
strcat(z,y);
printf("%s+%s=%s",y,x,z);
}
a)Add+string=Add string
b)syntax error during compilation
c)run time error/core dump
d)add+string=
e)none
(Ans will be e consider cap&small leters)
32)What does the following expression means?
char *(*(*a[N])())();
a) a pointer to a function returning array of n pointers to function
returnin
g
character pointers
b) a function return array of N pointers to funcions returning pointers
to
characters
c) an array of n pointers to function returning pointers to characters
d)an arrey of n pointers to function returning pointers to
functions returning pointers to characters
e) none of the above
(ANS IS d)
33)Which of the following is not a GDI object
a)HBRUSH
b)HPEN
c)HBITMAP
d)HRGN
e)HWND
(Ans ic e)
34) Which of the following message is used to initialize the
contents of a dialog
a)WM_CREATE
b)WM_SIZE
c)WM_COMMAND
d)WM_INITDIALOG
e)none
(Ans will be d)
35)Interprocess communication in UNIX can be achieved using
a)pipe
b)Message
c)Semaphores
d)Shared Memory
e)All of the above
(
Ans is e)
36) Which of the following is true
a)UNIX is a time sharing multi-user OS
b)UNIX has a device independent file system
c)UNIX is full duplex
d)UNIX has command interpreter
e)All of the above

(Ans is e)

45Q). PS1 pwd
export PS1 results in
a). your primary prompt being your current directory
b). " " and secondary prompts being the current dir
c). " " prompt being your home dir
d). " " and secondary prompts being the home dir
e). None of the above.
8Q). If you type in the command
nohup sort employees > list 2 > error out &
and log off ,the next time you log in . the output
will be
a). in a file called list and the error will de typed in
a file error out
b). there will be no file called list or error out
c). error will be logged in a file called list and o/p
will be in error out
d). you will not be allowed to log in
e). none of the above
7Q). In UNIX a files i-node
a)is a data structure that defines all specifications
of a file like the file size ,number of lines to a
file ,permissions etc.
b).----
c). - - - --
d). _ _ _
( ans is ---------(a) )
44Q). The UNIX shell is....
a).does not come with the rest of the system
b).forms the interface between the user and the kernal
c) does not give any scope for programming
d) deos not allow calling one program from with in another
e) all of the above
(ans is (b) )
48Q).enum number { a=-1, b= 4,c,d,e}
what is the value of e ?
7,4,5,15,3
(ans is 7 ) check again
3Q).The very first process created by the kernal that runs
till the kernal process is haltes is
a)init

b)getty
c)
d)
e)none
(Ans is a)
47 Q) Result of the following program is
main()
{
int i=0;
for(i=0;i<20;i++)
{
switch(i)
case 0:i+=5;
case 1:i+=2;
case 5:i+=5;
default i+=4;
break;}
printf("%d,",i);
}
}
a)0,5,9,13,17
b)5,9,13,17
c)12,17,22
d)16,21
e)syntax error
(Ans is d )
1 Q) What is the result
main()
{
char c=-64;
int i=-32
unsigned int u =-16;
if(c>i){
printf("pass1,");
if(c printf("pass2");
else
printf("Fail2");}
else
printf("Fail1);
if(i printf("pass2");
else
printf("Fail2")
}
a)Pass1,Pass2
b)Pass1,Fail2
c)Fail1,Pass2
d)Fail1,Fail2
e)none
(Ans is c)

2) In the process table entry for the kernel process, the process id value
is
a) 0 b) 1 c) 2 d) 255 e) it does not have a process table entry
Ans) a

4) Which of the following API is used to hide a window
a) ShowWindow
b) EnableWindow
c) MoveWindow
d) SetWindowPlacement
e)None of the above
Ans) a

5) what will the following program do?
void main()
{
int i;
char a[]="String";
char *p="New Sring";
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p); //Line no:9//

p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf("(%s, %s)",a,p);
free(p);
free(a);
} //Line no 15//

a) Swap contents of p & a and print:(New string, string)
b) Generate compilation error in line number 8
c) Generate compilation error in line number 5
d) Generate compilation error in line number 7
e) Generate compilation error in line number 1
Ans) b

6) In the following code segment what will be the result of the function,
value
of x , value of y

{
unsigned int x=-1;
int y;
y = ~0;
if(x == y)
printf("same");
else
printf("not same");
}

a) same, MAXINT, -1
b) not same, MAXINT, -MAXINT
c) same , MAXUNIT, -1
d) same, MAXUNIT, MAXUNIT
e) not same, MAXINT, MAXUNIT
Ans) a

37) PATH = /bin : /usr : /yourhome
The file /bin/calender has the following line in it
cal 10 1997
The file /yourhome/calender has the following line in it
cal 5 1997
If the current directory is /yourhome and calender is executed

a) The calendar for May 1997 will be printed on screen
b) The calendar for Oct 1997 will be printed on screen
c) The calendar for the current month( whatever it is) will be printed
d) Nothing will get printed on screen
e) An error massage will be printed

38) what will be the result of the following program ?
char *gxxx()
{
static char xxx[1024];
return xxx;
}

main()

{
char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is : %s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
Ans) b

39) What will be result of the following program?
void myalloc(char *x, int n)
{
x= (char *)malloc(n*sizeof(char));
memset(x,\0,n*sizeof(char));
}
main()
{
char *g="String";
myalloc(g,20);
strcpy(g,"Oldstring");
printf("The string is %s",g);
}
a) The string is : String
b) Run time error/Core dump
c) The string is : Oldstring
d) Syntax error during compilation
e) None of these
Ans) c ( check it )

40) which of the following function is used to repaint a window
immediately
a) Sendmessage(hWnd,WM_PAINt,......)
b) InvalidateRect(.......)
c) MoveWindow
d) WM_COPY
e) None

41) which function is the entry point for a DLL in MS Windows 3.1
a) main
b) Winmain
c) Dllmain
d) Libmain
e) None
Ans) b

42) The standard source for standard input , standard output and standard
error
is
a) the terminal
b) /dev/null
c) /usr/you/input, /usr/you/output/, /usr/you/error respectively
d) NOne

Ans) a

43) What will be the result of the following program?
main()
{
char p[]="String";
int x=0;

if(p=="String")
{
printf("Pass 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
else

{
printf("Fail 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
}

a) Pass 1, Pass 2
b) Fail 1, Fail 2
c) Pass 1, Fail 2
d) Fail 1, Pass 2
e) syntax error during compilation

46) Which of the choices is true for the mentioned declaration ?
const char *p;
and
char * const p;
a) You can't change the character in both
b) First : You can't change the characterr &
Second : You can;t change the pointer
c) You can't change the pointer in both
d) First : You can't change the pointer &
Second : You can't chanage the character
e) None
Ans) b ( check it)

49) The redirection operators > and >>

a) do the same function
b) differ : > overwrites, while >> appends
c) differ : > is used for input while >> is used for output
d) differ : > write to any file while >> write only to standard output
e) None of these
Ans) b

50) The command
grep first second third /usr/you/myfile

a) prints lines containing the words first, second or third from the
file
/usr/you/myfile
b) searches for lines containing the pattern first in the files second,
third
,
and /usr/you/myfile and prints them
c) searches the files /usr/you/myfiel and third for lines containing the
word
s
first or second and prints them

d) replaces the word first with the word second in the files third and
/usr/you/myfile

e) None of the above
Ans) b

). what will be the result of executing following program
main
{
char *x="new";
char *y="dictonary";
char *t;
void swap (char * , char *);
swap (x,y);
printf("(%s, %s)",x,y);

char *t;
t=x;
x=y;
y=t;
printf("-(%s, %s)",x,y);
}
void swap (char *x,char *y)
{
char *t;
y=x;
x=y;
y=t;
}

a).(New,Dictionary)-(New,Dictionary)
b).(Dictionary,New)-(New,Dictionary)
c).(New,Dictionary)-(Dictionary,New)
d).(Dictionary,New)-(Dictionary,New)
e).None of the above
(Ans will be b or e) check

Q10).If a directory contains public files (can be valied and used
by any one ) which should not be altered ,the most liberal
permissions that can be given to the directory is
a)755
b)777
c)757
d)775

e)None of the above
(Ans a)
11) what would the following program results in
main()
{
char p[]="string";
char t;
int i,j;
for(i=0,j=strlen(p);i {
t=p[i];
p[i]=p[j-i];
p[j-i]=t;
}
printf("%s",p);
}
a)will print:string
b)will not print anything since p will be pointing to a null string
c)will print:gnirtS
d)will result in a complication error
e)will print invallid characters(junk)
(Ans will be b ) check
12) After the following command is executed
$ ln old new

a listing is performed with the following output
$ ls -li

total 3
15768 -rw-rw-rw- 2 you 29 Sep 27 12:07 old
15768 " " " " " " " " new
15274 " " 1 " 40 " " 09:34 veryold

which of the following is true
a)old and new have same i-node number,2
b) " " " " " " " , 15768
c)old and new have nothing yo do with each other
d)very old and new are linked
e)very old and old are linked
(Ans is b)
13) What will be the result of executing the following statement
int i=10;
printf("%d %d %d",i,++i,i++);
a).10 11 12
b).12 11 10
c).10 11 11
d).result is OS dependent
e).result is compiler dependent
(Ans is e)
14) What does extern means in a function declaration
a)the funct has global scope
b)the funct need not be defined\
c)nothing really
d)the funct has local scope only to the file it is defined in
e)none of the above
(Ans will be c)
15) What will be result of the following program
main()
{
void f(int,int);
int i=10;
f(i,i++);
}
void f(int i,int j)
{
if(i>50)
return;
i+=j;
f(i,j);
printf("%d,",i);
}
a).85,53,32,21
b)10,11,21,32,53
c)21,32,53,85
d)32,21,11,10
e)none of the above
(Ans is e)
16). MS windows 3.1 is a
a)operating system
b)Application
c)Programing language
d)database
e)shell
(Ans will be b)
17).MS Windows 3.1 supports which tyoe of multi-tasking?
a)cycle
b)executive
c)preemptive
d)Non-preemptive
e)Manual
(Ans )
18)The command ......ln/bin/mail /usr/you/bin/m
a)will not be executed because you are linking files
across different file systems
b)results ln /bin/main being the same file as /usr/you/bin/m
c)results in 2 links to the file mail
d) " " " " m
e)none
(Ans will be b)
19)In a standerd directory lay out ,/etc is the directory where
a) basic programs such as who and ed reside
b) device related files reside
c)various administrative files such as password file reside
d) short-lived files created during program execution reside
e) the C sub-routine library resides
(Ans is c)
20) The command echo *
a) echoes all files in the current directory
b) prints * on the screen
c) is an invalid command
d) is the same as the command echo\*
e) is the same as echo"*"
(Ans is a)
21)What will be the result of the following segment of the program
main()
{
char *s="hello world";
int i=7;
printf("%.*%s",s);
}
a)syntax error
b)hello w
c) Hello
d) o world
e) none
(Ans is b)
22) What will be the result of the following program
main()
{
int a,b;
printf("enter two numbers :");
scanf("%d%d",a,b);
printf("%d+%d=%d",a,b,a+b);
}
a) will print the sum of the numbers entered
b) syntax error during compilation
c) will generate run time error /core dump
d) will print the string "a+b = a+b" on the screen
e) none of these
(Ans is c)
23) What is the size of 'q'in the following program?
union{
int x;
char y;
struct {
char x;
char y;
int xy;}p;
}q;
a)11
b)6
c)4
d)5
e)none
(Ans is b why because no of bytes for int =4 given in instructions)
24) Which message is displayed when a window is destroyed
a)WM_CLOSE
b)WM_DESTROY
c)WM_NCDESTROY
d)WM_POSTDESTROY
E)NONE
(Ans is b)
25)Send Message and postmessage are
a)send message puts the message in the message queue and results,
postmessage processes the message immediately
b)Sendmessage processes the message immediately,postmessage puts
the message in the queue and returns
c) Both put the message in the message queue and returns
d) Both process the message immediately
e) None of the above
(Ans will be b check)
26) Which of the following message is used to limit the size
of teh Window
a)WM_SIZE
b)WM_PAIN
c) WM_GETMINMAXINFO
d) WM_COMMAND
e) WM_CREATE
(Ans is a)

27)until who|grep mary
do
sleep 60
done
a) is syntactically incorrect
b) waits 60 seconds irrespective of Mary being logged in or not
c) waits until Marry is logged in
d)waits till Mary exited
e)None
(Ans is c)
28)The UNIX system call that transforms an executable binary file into
a process is
a)execl()
b)execv()
c)execle()
d)execve()
e)All of the above
(Ans will be e check)
29)Which of the following is true about fork()
a) it transforms an executable binary file into a process that
overlays the

process which made the fork() system call.NO new process is created.
b) Causes the creation of a new process, the CHILD process, with a new
process ID
c)Causes the creation of a new process, the CHILD process ,with the
same
process ID as the parent

d)fork() has nothing to do with processes
e)fork() is not a system call
(Ans is b)
30) What do the following variable names represents?
sort register
volatile default
a) short - is not a reserved keyword
b ) volatile & register - is not a reserved keyword
c)all the above are keywords
d) all are valid variable names
e) default - is not a reserved keyword
(Ans is c)
31)What will be the result of the following program
main()
{
char *x="String";
char y[] = "add";
char *z;
z=(char *) malloc(sizeof(x)+sizeof(y)=1);
strcpy(z,y);
strcat(z,y);
printf("%s+%s=%s",y,x,z);
}
a)Add+string=Add string
b)syntax error during compilation
c)run time error/core dump
d)add+string=
e)none
(Ans will be e consider cap&small leters)
32)What does the following expression means?
char *(*(*a[N])())();
a) a pointer to a function returning array of n pointers to function
returnin
g
character pointers
b) a function return array of N pointers to funcions returning pointers
to
characters
c) an array of n pointers to function returning pointers to characters
d)an arrey of n pointers to function returning pointers to
functions returning pointers to characters
e) none of the above
(ANS IS d)
33)Which of the following is not a GDI object
a)HBRUSH
b)HPEN
c)HBITMAP
d)HRGN
e)HWND
(Ans ic e)
34) Which of the following message is used to initialize the
contents of a dialog
a)WM_CREATE
b)WM_SIZE
c)WM_COMMAND
d)WM_INITDIALOG
e)none
(Ans will be d)
35)Interprocess communication in UNIX can be achieved using
a)pipe
b)Message
c)Semaphores
d)Shared Memory
e)All of the above
(
Ans is e)
36) Which of the following is true
a)UNIX is a time sharing multi-user OS
b)UNIX has a device independent file system
c)UNIX is full duplex
d)UNIX has command interpreter
e)All of the above
(Ans is e)

45Q). PS1 pwd
export PS1 results in
a). your primary prompt being your current directory
b). " " and secondary prompts being the current dir
c). " " prompt being your home dir
d). " " and secondary prompts being the home dir
e). None of the above.
8Q). If you type in the command
nohup sort employees > list 2 > error out &
and log off ,the next time you log in . the output
will be
a). in a file called list and the error will de typed in
a file error out
b). there will be no file called list or error out
c). error will be logged in a file called list and o/p
will be in error out
d). you will not be allowed to log in
e). none of the above
7Q). In UNIX a files i-node
a)is a data structure that defines all specifications
of a file like the file size ,number of lines to a
file ,permissions etc.
b).----
c). - - - --
d). _ _ _
( ans is ---------(a) )
44Q). The UNIX shell is....
a).does not come with the rest of the system
b).forms the interface between the user and the kernal
c) does not give any scope for programming
d) deos not allow calling one program from with in another
e) all of the above
(ans is (b) )

48Q).enum number { a=-1, b= 4,c,d,e}
what is the value of e ?
7,4,5,15,3
(ans is 7 ) check again
3Q).The very first process created by the kernal that runs
till the kernal process is haltes is
a)init
b)getty
c)
d)
e)none
(Ans is a)
47 Q) Result of the following program is
main()
{
int i=0;
for(i=0;i<20;i++)
{
switch(i)
case 0:i+=5;
case 1:i+=2;
case 5:i+=5;
default i+=4;
break;}
printf("%d,",i);
}
}
a)0,5,9,13,17
b)5,9,13,17
c)12,17,22
d)16,21
e)syntax error
(Ans is d )
1 Q) What is the result
main()
{
char c=-64;
int i=-32
unsigned int u =-16;
if(c>i){
printf("pass1,");
if(c printf("pass2");
else
printf("Fail2");}
else
printf("Fail1);
if(i printf("pass2");
else
printf("Fail2")
}
a)Pass1,Pass2
b)Pass1,Fail2
c)Fail1,Pass2
d)Fail1,Fail2
e)none
(Ans is c)

2) In the process table entry for the kernel process, the process id value
is
a) 0 b) 1 c) 2 d) 255 e) it does not have a process table entry
Ans) a

4) Which of the following API is used to hide a window
a) ShowWindow
b) EnableWindow
c) MoveWindow
d) SetWindowPlacement
e)None of the above
Ans) a

5) what will the following program do?
void main()
{
int i;
char a[]="String";
char *p="New Sring";
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p); //Line no:9//
p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf("(%s, %s)",a,p);
free(p);

free(a);
} //Line no 15//

a) Swap contents of p & a and print:(New string, string)
b) Generate compilation error in line number 8
c) Generate compilation error in line number 5
d) Generate compilation error in line number 7
e) Generate compilation error in line number 1
Ans) b
6) In the following code segment what will be the result of the function,
value
of x , value of y

{
unsigned int x=-1;
int y;
y = ~0;
if(x == y)
printf("same");

else
printf("not same");
}

a) same, MAXINT, -1
b) not same, MAXINT, -MAXINT
c) same , MAXUNIT, -1
d) same, MAXUNIT, MAXUNIT
e) not same, MAXINT, MAXUNIT
Ans) a

37) PATH = /bin : /usr : /yourhome
The file /bin/calender has the following line in it
cal 10 1997
The file /yourhome/calender has the following line in it
cal 5 1997
If the current directory is /yourhome and calender is executed

a) The calendar for May 1997 will be printed on screen
b) The calendar for Oct 1997 will be printed on screen
c) The calendar for the current month( whatever it is) will be printed
d) Nothing will get printed on screen
e) An error massage will be printed

38) what will be the result of the following program ?
char *gxxx()
{
static char xxx[1024];
return xxx;
}

main()
{
char *g="string";
strcpy(gxxx(),g);

g = gxxx();
strcpy(g,"oldstring");
printf("The string is : %s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
Ans) b

39) What will be result of the following program?
void myalloc(char *x, int n)
{
x= (char *)malloc(n*sizeof(char));
memset(x,\0,n*sizeof(char));
}
main()
{
char *g="String";
myalloc(g,20);
strcpy(g,"Oldstring");
printf("The string is %s",g);
}
a) The string is : String
b) Run time error/Core dump
c) The string is : Oldstring
d) Syntax error during compilation
e) None of these
Ans) c ( check it )

40) which of the following function is used to repaint a window
immediately
a) Sendmessage(hWnd,WM_PAINt,......)
b) InvalidateRect(.......)
c) MoveWindow
d) WM_COPY
e) None

41) which function is the entry point for a DLL in MS Windows 3.1
a) main
b) Winmain
c) Dllmain
d) Libmain
e) None
Ans) b

42) The standard source for standard input , standard output and standard
error
is
a) the terminal
b) /dev/null
c) /usr/you/input, /usr/you/output/, /usr/you/error respectively
d) NOne
Ans) a

43) What will be the result of the following program?
main()
{
char p[]="String";
int x=0;

if(p=="String")
{
printf("Pass 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
else
{
printf("Fail 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
}

a) Pass 1, Pass 2
b) Fail 1, Fail 2
c) Pass 1, Fail 2
d) Fail 1, Pass 2
e) syntax error during compilation

46) Which of the choices is true for the mentioned declaration ?
const char *p;
and
char * const p;
a) You can't change the character in both
b) First : You can't change the characterr &

Second : You can;t change the pointer
c) You can't change the pointer in both
d) First : You can't change the pointer &
Second : You can't chanage the character
e) None
Ans) b ( check it)

49) The redirection operators > and >>

a) do the same function
b) differ : > overwrites, while >> appends
c) differ : > is used for input while >> is used for output
d) differ : > write to any file while >> write only to standard output
e) None of these
Ans) b

50) The command
grep first second third /usr/you/myfile

a) prints lines containing the words first, second or third from the
file
/usr/you/myfile
b) searches for lines containing the pattern first in the files second,
third
,
and /usr/you/myfile and prints them
c) searches the files /usr/you/myfiel and third for lines containing the
word
s
first or second and prints them
d) replaces the word first with the word second in the files third and
/usr/you/myfile
e) None of the above
Ans) b

C-language. 48 questions - 45 min.
1. Diff.between inlinefunction((++)-macns(c)
2. 3 to 4 questions on conditional operator :?:
3. Write a macro for sqaring no.
4. Trees -3 noded tree ( 4 to 5 questions fundamentals)
Maximum possible no.of arrnging these nodes
5. Arrange the nodes in depth first order
breadth first order
6. Linked lists Q) Given two statments
1. Allocating memory dynamiccaly
2. Arrays
Tree the above both and find the mistake
7. Pointers (7 to 8 questions) Schaum series
Pointer to functions, to arrays
4 statements ->meaning,syntax for another 4 statements
8. Booting-def(When you on the system the process that takes place is ------
9. -----Type of global variable can be accessible from any where in the
working environment ( external global variable)
10. Which of the following can be accessed randomly
Ans. a. one way linked list
b. two way "
c. Arrays
d. Trees
11. Write a class for a cycle purchase(data items req.)

1.Max value of SIGNED int
a. b. c. d.
2.One questin is given, long one, to find the answer U should be
femiliar
with the operation as follows
int *num={10,1,5,22,90};
main()
{
int *p,*q;
int i;
p=num;
q=num+2;
i=*p++;
print the value of i, and q-p, and some other operations are there.
}
how the values will change??
3. One pointer diff is given like this:
int *(*p[10])(char *, char*)
asked to find the meaning.
4. char *a[4]={"jaya","mahe","chandra","buchi"};
what is the value of sizeof(a)/sizeof(char *)
a. 4 b.bytes for char c-- d.--
( we don't know the answer)
5. void fn(int *a, int *b)
{
int *t;
t=a;
a=b;
b=t;
}
main()
{
int a=2;
int b=3;
fn(&a,&b);
print the values os a and b;
}
what is the output--- out put won't swap, the same values remain.
a. error at runtime
b. compilation error
c.2 3
d. 3 2
6.
#define scanf "%s is a string"
main()
{
printf(scanf,scanf);
}
what is the output.
ANS : %s is string is string
7. i=2+3,4>3,1;
printf("%d"i);
ans is 5 only.
8. char *p="abc";
char *q="abc123";
while(*p=*q)
{
print("%c %c",*p,*q);
}
a. aabbcc
b. aabbcc123
c. abcabc123
d. infinate loop ( this may be correct)
9. printf("%u",-1)
what is the value?
a. -1 b. 1 c. 65336 d. --

(maxint value-1 I think, check for the answer)
10. #define void int
int i=300;
void main(void)
{
int i=200;
{
int i=100;
print the value of i;
}
print the value of i
}
what is the output?

may be 100 200
11.
int x=2;
x=x<<2;
printf("%d ",x);

ANS=8;
12.
int a[]={0,0X4,4,9}; /*some values are given*/
int i=2;
printf("%d %d",a[i],i[a]);
what is the value??? (may be error)
13.
some other program is given , I can't remember it
U can get it afterwads,
the answer is 3 3, so U can check this in the exam. itself.
I'll send the remaining two afterwars whenever I get them. OK !



14.



1. Which of the following language is predecessor to C Programming Language?
A B BCPL C++
Ans : 2
2. C programming language was developed by
Dennis Ritchie Ken Thompson Bill Gates Peter Norton
Ans : 1
3. C was developed in the year ___
1970 1972 1976 1980
Ans : 2
4. C is a ___ language
High Level Low Level Middle Level Machine Level
Ans : 3
5. C language is available for which of the following Operating Systems?
DOS Windows Unix All of these
Ans : 4
6. Which of the following symbol is used to denote a pre-processor statement?
! # ~ ;
Ans : 2
7. Which of the following is a Scalar Data type
Float Union Array Pointer
Ans : 1
8. Which of the following are tokens in C?
Keywords Variables Constants All of the above
Ans : 4
9. What is the valid range of numbers for int type of data?
0 to 256 -32768 to +32767 -65536 to +65536 No specific range
Ans : 1
10. Which symbol is used as a statement terminator in C?
! # ~ ;
Ans : 4
11. Which escape character can be used to begin a new line in C?
\a \b \m \n
Ans : 4
12. Which escape character can be used to beep from speaker in C?
\a \b \m \n
Ans : 2
13. Character constants should be enclosed between ___
Single quotes Double quotes Both a and b None of these
Ans : 2
14. String constants should be enclosed between ___
Single quotes Double quotes Both a and b None of these
Ans : 1
15. Which of the following is invalid?
‘’ “ “ ‘a’ ‘abc’
Ans : 4
16. The maximum length of a variable in C is ___
8 16 32 64
Ans : 1
17. What will be the maximum size of a float variable?
1 byte 2 bytes 4 bytes 8 bytes
Ans : 2
18. What will be the maximum size of a double variable?
1 byte 4 bytes 8 bytes 16 bytes
Ans : 4
19. A declaration float a,b; occupies ___ of memory
1 byte 4 bytes 8 bytes 16 bytes
Ans : 2
20. The size of a String variable is
1 byte 8 bytes 16 bytes None of these
Ans : 4

Objective-C through a preprocessor
Question
Can Objective-C be implemented by translating it into C?
Answer
The concise answer is yes, in fact contemporary Objective-C implementations, as provided by for instance Stepstone and BPG, actually translate Objective-C to C which in turn is processed by the C compiler already present on the system. However, one must not forget that (most of) the power of Objective-C is provided by the Objective-C runtime library, which has nothing to do with the Objective-C compiler other than that the compiler generates code which calls the library.
A program translating Objective-C to C needs to perform the following actions:
 Translate instance variable declarations in a class interface into a structure definition. Each generated structure describes all instance variables of the class' instances.
 Translate every method implementation into a function with exactly the same arguments as the method, plus the implicit first two arguments self and _cmd. Within the method, all references to an instance variable ivar translate to self->ivar.
 Translate every method invocation into a lookup of the function implementing the method for this object, followed by an invocation of that function. (On NeXT's runtime, both the lookup and invocation are performed by a single function).
 For every message sent to a named class, like alloc in [[MyClass alloc] init], invoke a runtime library function to obtain the class object to which the factory message can be sent.
 For every object file created, build the data structures used by the runtime for every class implementation and protocol declaration. Also output a constructor function to have the runtime library add the information in this object file to its data structures.
 All Objective-C specific warnings and errors must be generated by the translator, since obviously the C compiler has no notion of Objective-C concepts.
An existing, available Objective-C Translator is OCT though a quick glance shows it seems both rather Amiga oriented and old (i.e. there is no ./configure, me spoiled brat).
1) Find the output for the following C program
main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
Ans. An empty string

2) Find the output for the following C program
main()
{
int x=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf("%d %d\n",x,y);
}
Ans. 57 94

3) Find the output for the following C program
main()
{
int x=5;
printf("%d %d %d\n",x,x<<2,x>>2);
}
Ans. 5 20 1

4) Find the output for the following C program
#define swap1(a,b) a=a+b;b=a-b;a=a-b;
main()
{
int x=5,y=10;
swap1(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;
}
Ans. 10 5

5) Find the output for the following C program
main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}
Ans. Samco Systems

6) Find the output for the following C program
#include
main()
{
char s1[]="Ramco";
char s2[]="Systems";
s1=s2;
printf("%s",s1);
}
Ans. Compilation error giving it cannot be an modifiable 'lvalue'

7) Find the output for the following C program
#include
main()
{
char *p1;
char *p2;
p1=(char *) malloc(25);
p2=(char *) malloc(25);
strcpy(p1,"Ramco");
strcpy(p2,"Systems");
strcat(p1,p2);
printf("%s",p1);
}
Ans. RamcoSystems

8) Find the output for the following C program given that
[1]. The following variable is available in file1.c
static int average_float;
Ans. All the functions in the file1.c can access the variable

9) Find the output for the following C program
# define TRUE 0
some code
while(TRUE)
{
some code
}
Ans. This won't go into the loop as TRUE is defined as 0

10) Find the output for the following C program
main()
{
int x=10;
x++;
change_value(x);
x++;
Modify_value();
printf("First output: %d\n",x);
}
x++;
change_value(x);
printf("Second Output : %d\n",x);
Modify_value(x);
printf("Third Output : %d\n",x);
}
Modify_value()
{
return (x+=10);
}
change_value()
{
return(x+=1);
}
Ans. 12 1 1

11) Find the output for the following C program
main()
{
int x=10,y=15;
x=x++;
y=++y;
printf("%d %d\n",x,y);
}
Ans. 11 16

12) Find the output for the following C program
main()
{
int a=0;
if(a=0) printf("Ramco Systems\n");
printf("Ramco Systems\n");
}
Ans. Ony one time "Ramco Systems" will be printed

13) Find the output for the following C program
#include
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(;isum+=array[i];
return sum;
}

Q14) Find the output for the following C program
#include
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.0;
printf(myformat,ave);
}

Q15) Find the output for the following C program
#include
void main(void);
{
int a[10];
printf("%d",((a+9) + (a+1)));
}

Q16) Find the output for the following C program
#include
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);
}

Q17) Find the output for the following C program
#include
void main(void)
{
unsigned int c;
unsigned x=0x3;
scanf("%u",&c);
switch(c&x)
{
case 3: printf("Hello!\t");
case 2: printf("Welcome\t");
case 1: printf("To All\t");
default:printf("\n");
}
}

Q18) Find the output for the following C program
#include
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);
}

Q19) Find the output for the following C program
#include
void main(void);
{
char numbers[5][6]={"Zero","One","Two","Three","Four"};
printf("%s is %c",&numbers[4][0],numbers[0][0]);
}

Q20) Find the output for the following C program
int bags[5]={20,5,20,3,20};
void main(void)
{
int pos=5,*next();
*next()=pos;
printf("%d %d %d",pos,*next(),bags[0]);
}
int *next()
{
int i;
for(i=0;i<5;i++)
if (bags[i]==20)
return(bags+i);
printf("Error!");
exit(0);
}

Q21) Find the output for the following C program
#include
void main(void)
{
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);
}

Q22) Find the output for the following C program
#include
void main(void);
{
double dbl=20.4530,d=4.5710,dblvar3;
double dbln(void);
dblvar3=dbln();
printf("%.2f\t%.2f\t%.2f\n",dbl,d,dblvar3);
}
double dbln(void)
{
double dblvar3;
dbl=dblvar3=4.5;
return(dbl+d+dblvar3);
}

Q23) Find the output for the following C program
#include
static int i=5;
void main(void)
{
int sum=0;
do
{
sum+=(1/i);
}while(0}

Q24) Find the output for the following C program
#include
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;
}

Q25) Find the output for the following C program
#include
void main(void);
{
int i=100,j=20;
i++=j;
i*=j;
printf("%d\t%d\n",i,j);
}

Q26) Find the output for the following C program
#include
void main(void);
int newval(int);
void main(void)
{
int ia[]={12,24,45,0};
int i;
int 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++);
}

Q27) Find the output for the following C program
#include
void main(void);
{
int var1,var2,var3,minmax;
var1=5;
var2=5;
var3=6;
minmax=(var1>var2)?(var1>var3)?var1:var3:(var2>var3)?var2:var3;
printf("%d\n",minmax);

Q28) Find the output for the following C program
#include
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;iprintf("%d\n",*(a++)+i);
}

Q29) Find the output for the following C program
#include
void main(void);
void print(void);
{
print();
}
void f1(void)
{
printf("\nf1():");
}

Q30) Find the output for the following C program
#include "6.c"
void print(void)
{
extern void f1(void);
f1();
}
static void f1(void)
{
printf("\n static f1().");
}

Q31) Find the output for the following C program
#include
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--);
}

Q32) Find the output for the following C program
#include
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);
}

Q33) Find the output for the following C program
#include
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);
}

1. Which of following operator can't be overloaded.
a) ==
b) ++
c) ?!
d) <=
2. For the following C program
#include
main()
{printf("Hello World");}
The program prints Hello World without changing main() ,the output should
be
intialisation
Hello World
Desruct
The changes should be
a) IOstream operator<<(iostream os, char*s)
os<<'intialisation'<<(Hello World)<b)
c)
d) none of the above
3. CDPATH shell variable is in(c-shell)
4. The term stickily bit is related to
a) Kernel
b) Undeletable file
c) Both (a) and (b)
d) None
5. Semaphore variable is different from ordinary variable by
6. For the following C program:
swap(int x,y)
{ int temp;
temp=x;
x=y;
y=temp;}
main()
{int x=2;y=3;
swap(x,y);}
After calling swap, what are the values x & y?
7. Static variable will be visible in
a) Function. in which they are defined
b) Module in which they are defined
c) All the program
d) None
8. Unix system is
a) Multi processing
b) Multi processing, multiuser
c) Multi processing, multiuser, multitasking
d) Multiuser, multitasking

9. X.25 protocol encapsulates the follwing layers
a) Network
b) Datalink
c) Physical
d) All of the above
e) None of the above
10. TCP/IP can work on
a) Ethernet
b) Tokenring
c) (a) & (b)
d) None
11. A node has the IP address 138.50.10.7 and 138.50.10.9.
But it is transmitting data from node1 to node 2only.
The reason may be
a) A node cannot have more than one address
b) class A should have second octet different
c) class B should have second octed different
d) All of the above
12. The OSI layer from bottom to top
13. For an application which exceeds 64k the memory model should be
a) Medium
b) Huge
c) Large
d) None
14. The condition required for dead lock in unix system is
15. Set-user-id is related to (in unix)
16. Bourne shell has
a) History record****other choices not given
17. Which of the following is not true about C++
a) Code removably
b) Encapsulation of data and code
c) Program easy maintenance
d) Program runs faster
18. For the following C program
struct base {int a,b;
base();
int virtual function1();}
struct derv1:base
{int b,c,d;
derv1()
int virtual function1();}
struct derv2 : base
{int a,e;
}
base::base()
{a=2;b=3;
}
derv1::derv1()
{b=5;
c=10;d=11;}
base::function1()
{return(100);
}
derv1::function1()
{
return(200);
}
main()
base ba;
derv1 d1,d2;
printf("%d %d",d1.a,d1.b)
Output of the program is:
a) a=2;b=3;
b) a=3; b=2;
c) a=5; b=10;
d) none
19. For the above program answer the following q's
main()
base da;
derv1 d1;
derv2 d2;
printf("%d %d %d",da.function1(),d1.function1(),d2.function1());
Output is:
a) 100,200,200;
b) 200,100,200;
c) 200,200,100;
d) None of the above
20. For the following C program
struct {
int x;
int y;
}abc;
x cannot be accessed by the following
1)abc-->x;
2)abc[0]-->x;
3)abc.x;
4)(abc)-->x;
a )1, 2, 3
b) 2 & 3
c) 1 & 2
d) 1, 3, 4

21. Automatic variables are destroyed after fn. ends because
a) Stored in swap
b) Stored in stack and poped out after fn. returns
c) Stored in data area
d) Stored in disk
22. Relation between x-application and x-server (x-win)
23. What is UIL(user interface language) (x-win)
24)Which of the following is right in ms-windows
a) Application has single qvalue system has multiple qvalue
b) Application has multiple qvalue system has single qvalue
c) Application has multipleqvalue system has multiple qvalue
d) None
25. Widget in x-windows is
26. Gadget in x_windows is
27. Variable DESTDIR in make program is accessed as
a) $(DESTDIR)
b) ${DESTDIR}
c) DESTDIR
28. The keystroke mouse entrie are interpreted in ms windows as
a) Interrupt
b) Message
c) Event
d) None of the above
29. Link between program and outside world (ms -win)
a) Device driver and hardware disk
b) Application and device driver
c) Application and hardware device
d) None
30. Ms -windows is
a)multitasking
b)multiuser
c) bothof the above
d) none of the above

31. Dynamic scoping is

32. After logout the process still runs in the background by giving the command
33. Which process dies out but still waits
a) Exit
b) Wakeup
c) Zombie
d) Sleep
34. In dynamic memory allocation we use
a) Doubly linked list
b) Circularly linked
c) B trees
d) L trees
e) None
35. To find the key of search the data structure is
a) Hash key
b) Trees
c) Linked lists
d) Records
36. Which of the following is true
a) Bridge connects dissimiler LANand protocol insensitive
b) Router connects dissimiler LANand protocol insensitive
c) Gateway connects dissimiler LANand protocol insensitive
d) None of the above

37. Read types of tree traversals.
38. Read about SQL/Databases
39.A DBMS table is given along with simple SQL statements. Find the output.
40. Simple programs on pointers in c

1. For the following program.
struct XXX
{int a;
float b;
char *s;
}X;
If optimization :X not used in compiler then unused bits_________________.
Give your assumption_______________.

2. Give the output of the following program
struct XXX
{int a:6;
float b:4;
char s;
}structure;
size of (structure);

3.Class used for the multiple inheritence in JAVA_________________
(a) anonymous class
(b) inner class
(c) abstreet class
(d) none

4. XDR fixes in which part of OS1 stack.

5. LDAP is____________service protocol.

6. Given definition for a function which returns a array of pointers with argument of int*.

7. Give a function declaration with no arguments which refers a two dimensional array

8. Pick up the correct function declaration.
1. void *[] name();
2. void int[][] name();
3. void ** name();
4. none of the above.

9. Give the difference between monolithic and microlithic kernal:
a. monolithic large
b. microlithic used in embedded systems.
c. none.

10. rPC coresponds to_______________in OSI stack.

11. Find the no.of page faults using LRU stack.
eg.3 4 4 6 7 8 1 2 .. ..

12.The inorder representation of a tree 41523 and preorder is 211513 Draw it?

13. When does a stack member will be initialised
(a) when object is created
(b) when object is initialised.
(c) doesnot depend on object.
(d) none.

14. Number of CPU in a multiprocess is contrassed by
(a) RISC nohere of CPU
(b) memory
(c) both (a) and (b)
(d) None of the above
15. Give the output of the following program
main()
{char *s;
s="hot java";
strcpy(s,"solarrs java")
}
16. Give the output of the following program
main()
{printf("hot java");
fork()
exit(0);
}
(i). When redirected to a screen what will be printed.
(ii). When redirected to file what will be printed.

17. Give the output of the following program
main()
{int ret;
ret=fork();ret=fork();ret=fork();ret=fork();
if(!ret)
printf("sun");
else
printf("solaris");

18. Give the output of the following program
main()
{char *p='a';
int *i=100/*p;
}
what will be the value of *i= 1

19. Which data structure gives efficient search
1 B-tree
2 binary tree
3 array
4 linked list

20. Find the error in the following program
struct point
{struct point *next;
int data;
}
x;
main()
{int i;
for(x=p;x!=0;)
x=x->next,x++;
freelist(x);
}
freelist(x)
{free(x);
return
}

21. Mutex and _________are similar locking mechanisms.

22. A complex question on pointers and functions.

23. SNMP and SMIP transport layer protocols for TCP/IP&OSI.

24 UNIX: difference between select and poll`

Admonish : usurp Meager :scanty Alienate : estrange
Merry : gay Brim : Boarder obstinate : stubborn
Pretention:pretentioius Tranquil:serene solicit : urge
subside : wane furtive :stealthy misery : disstress
volume :quantity veer : diverge stiffle :sniths
adhesive : --- Hamper : obstruct belief : conviction
lament : wail to merit :to deserve incentive : ----
inert: passive Baffle : Frustrate Confiscate : appropriat
Covet : crave Caprice : whim Concur :acquiesce
Cargo :freight Dispel : Scatter Divulge : -----
Discretion: prudence Emancipate : liberate Efface : obliterate
Hover : linger Heap : to pile Instigate : incite
latitude : scope latent : potential lethergy : stupor
momentary : transient
----- means , for these words we are not able to reproduce answers.

PART II QUANTITATIVE APTITUDE ,TIME 20 Min. MARKS :30.
-----------------------------------------------------------------
1. Two pencils costs 8 cents, then 5 pencils cost how much
(Ans:20 cents).

2. A work is done by the people in 24 min. one of them can do
this work a lonely in 40 min. how much time required to do the same
work for the second person.
(ans:60 min.)

3. A car is filled with four and half gallons of oil for full round
trip. fuel is taken 1/4 gallons mor3 in going than coming. what is
the fiel consumed in coming up? (2 gallons)

4. low temperature at the night in a city is 1/3 more than 1/2
hinge as higher temperature in a day. sum of the low temp and
higherst temp is 100C. then what is the low temperature (40 C)

5. A person who decided to go weekend trip should not exceed 8 hours
driving in a day Average speed of forward journy is 40 mph. due to
traffic in sundays, the return journey average speed is 30 mph.
how far he can select a picnic spot (120 miles).

6. A sales person multiplied a number and get the answer is 3,
instead of that number divided by 3. what is th answer he actually
has to get ? (1/3).

7. A ship started from port and moving with I mph and another ship
started from L and moving with H mph. At which place these two ships
meet ? ( Ans is between I and J and close to J)

!_____!_____!_____!_____!_____!_____!
port G H I J K L

8. A building with hight D ft shadow upto G A neighbour building with


!_____!_____!_____!_____!_____!_____!_____!
A B C D E F G H

9. A person was fined for exceeding the speed limit by 10 mph.Another
person was also fined for exceeding the same speed limit by twice
the same. If the second person was travelling at a speed of 35 mph.
find the speed limit (15 mph)

10. A bus started from bustand at 8.00a m and after 30 min staying at
destination, it returned back to the bustand. the destination is 27
miles from the bustand. the speed of the bus 50 percent fast speed.
at what time it retur4ns to the bustand (11.00)

11.in a mixture, R is 2 parts, S is 1 part. in order to make S to 25%
of the mixture, howmuch R is to be added ( one part).

12. wind flows 160 miles in 330 min, for 80 miles how much time
required.
13. with 4/5 full tank vehicle travels 12 miles, with 1/3 full tank
how much distance travels ( 5 miles).

14. two trees are there. one grows at 3/5 of the other. in 4 years,
total growth of trees is 8 ft. what growth will smaller tree will
have in 2 years. (<2ft)

15. A storm will move with a velocity of towords the center in
hours. At the same rate how much far will it move in hrs.
(but Ans is 8/3 or 2 2/3).

PART III: TIME 25 Min, MARKS :50.
-----------------------------------------------
CRITICAL REASONING : THERE WILL BE 13 PASSAGES WITH 50 QUESTIONS TIME
30 MIN. HERE I AM SENDING ONLY SOME OF THE PASSAGES (these will give
only rough idea)
(ANSWERS WILL BE AS YES/NO/CAN'T SAY we are giving our answers,
please check.)

1. My father has no brothers. he has three sisters who has two childs
each.

1> my grandfather has two sons (f)
2> three of my aunts have two sons(can't say)
3> my father is only child to his father(f)
4> i have six cousins from my mother side(f)
5> i have one uncle(f)

2. Ether injected into gallablader to dissolve galstones. this type
oneday treatment is enough for gallstones not for calcium stones. this
method is alternative to surgery for millions of people who are suf
fering from this disease.

1> calcium stones can be cured in oneday (f)
2> hundreds of people contains calcium stones(can't say)

4> Eather will be injected into the gallbleder to cure the
cholestrol
based gall stones(t).

3. Hacking is illigal entry into other computer. this is done
mostly
because of lack of knowledge of computer networking with networks
one
machine can access to another machine. hacking go about without
know
ing that each network is accredited to use network facility.

1> Hacking people never break the code of the company
which
they work for (can't say).
2> Hacking is the only vulnerability of the computers for
the usage
of the data.(f)
3> Hacking is done mostly due to the lack of computer
knowledge (f).
(there will be some more questions in this one )

4. alphine tunnels are closed tunnels. in the past 30 yrs not
even a
single accident has been recorded for there is one accident in
the
rail road system. even in case of a fire accident it is possible
to
shift the passengers into adjacent wagons and even the living
fire can
be detected and extinguished with in the duration of 30 min.

1> no accident can occur in the closed tunnels (True)
2> fire is allowed to live for 30 min. (False)
3> All the care that travel in the tunnels will be
carried by rail
shutters.(t)
4>

5. In the past helicopters are forced to ground or crash because
of
the formation of the ice on the rotors and engines. a new
electronic
device has been developed which can detect the watercontent in
the
atmosphere and warns the pilot if the temp.is below freezing
temp.
about the formation of the ice on the rotors and wings.

1> the electronic device can avoid formation of the ice on the
wings
False).
2> There will be the malfunction of rotor & engine because of
forma
tion of ice (t)
3> The helicopters are to be crashed or down (t)
4> There is only one device that warn about the formation of
ice(t).

6.

In the survey conducted in mumbai out of 63 newly married house
wives not a single house wife felt that the husbands should take equal
part in the household work as they felt they loose their power over
their husbands. inspite of their careers they opt to do the kitchen
work themselves after coming back to home. the wives get half as much
leisure time as the husbands get at the week ends.

1> housewives want the husbands to take part equally in the
household(f)
2> wives have half as much leisure time as the husbands have(f)
3> 39% of the men will work equally in the house in cleaning and
washing
3>

port and technology development was less & it took place weeks
to
comunicate a message at that time. wherein we can send it
through
satellite with in no time ----------. even with this fast
develop
ments it has become difficult to understand each other.

1> people were not intelligent during Copernicus days (f).
2> Transport facilities are very much improved in noe a days
(can'
say)
3> Even with the fast developments of the techonology we can't
live
happily.(can't say)
4> We can understand the people very much with the development
of
communication(f).

Q8) senior managers warned the workers that because of the
intfoduc
tors of japanese industry in the car market. There is the
threat to
the workers.



They also said that there will be the reduction in the purchase
of the sales of car in public.the interest rates of the car will be
increased with the loss in demand.

1> japanese workers are taking over the jobs of indian
industry.(false)
2> managers said car interests will go down after seeing the raise
in interest rates.(true)
3> japanese investments are ceasing to end in the car industry.(false)
4> people are very much interested to buy the cars.(false)

Q9) In the totalitariturican days,the words have very much devalued.In
the present day,they are becoming domestic that is the words will be
much more devalued. In that days, the words will be very much effect
ed in political area. but at present,the words came very cheap .we
can say they come free at cost.

1> totalitarian society words are devalued.(false)
2> totalitarian will have to come much about words(t)
3> The art totalitatian society the words are used for the polit
ical speeches.
4>

Q10) There should be copyright for all arts. The reele has came that
all the arts has come under one copy right society,they were use the
money that come from the arts for the developments . There may be a
lot of money will come from the Tagore works. We have to ask the
benifiters from Tagore work to help for the development of his works.

1> Tagore works are came under this copy right rule.(f)
2> People are free to go to the because of the copy right
rule.(can't say)
3> People gives to theater and collect the money for
development.(can't say)
4> We have ask the Tagore resedents to help for the developments of
art.(can't say)

NOTE : DO 1,2,3,4,5 PASSAGES WHICH ARE EASY. LAST BUT ONE ALSO. DO
THAT PASSAGES CAREFULLY. TIME WILL BE INSUFFICIENT. PASSAGES ARE NOT
AS EXACTLY AS ABOVE. THERE IS HIGHLEVEL ENGLISH IN ALL THE PASSAGES,
ENGLISH THERE. WHILE ANSWERING U SHOULD BE VERY FAST, DO NOT
WASTE
TIME, IT IS INSUFFICIENT,TRY TO ANSWER AS MANY AS POSSIBLE.

SECTION 4. PSYCHOMETRIC TEST.
----------------------------------------
DO NOT BOTHERE ABOUT MUCH ABOUT THIS TEST. BE OPTIMISTIC WHILE
ANSWERE.
THERE WILL BE 150 QUESTIONS IN 30 MIN. THE QUESTIONS IN THIS
SECTION MAY
REPEATED WITH SLIGHT VARIATIONS ANSWER SHOULD BE SAME IN BOTH THE
CASES.
(ans will be as yes/no/can't say)

for example
1> you will be interested in social activities.
2> while going upstairs you will move two steps at a time.
3> you will be making friendship with same sex or with opposite
sex also.
4> your friends will consider u as a leader in your group
5> people think that your'e serious minded.
6> some times you feel dull without any reason.
7> your'e host or hostes for several parties.
8> relatives come to your house you will entertain them.
9> you will do work for longtime without tireness.
10> in your company you want lead the organasition.
etc.. the qwestions may repeate several times so becareful and
give same ans's.



This test consists of 50 questions. The Set Code for this paper is D.
1. The C language terminator is
(a) semicolon
(b) colon
(c) period
(d) exclamation mark

2. What is false about the following -- A compound statement is
(a) A set of simple statments
(b) Demarcated on either side by curly brackets
(c) Can be used in place of simple statement
(d) A C function is not a compound statement.

3. What is true about the following C Functions
(a) Need not return any value
(b) Should always return an integer
(c) Should always return a float
(d) Should always return more than one value

4. Main must be written as
(a) The first function in the program
(b) Second function in the program
(c) Last function in the program
(d) Any where in the program

5. Which of the following about automatic variables within a function is correct ?
(a) Its type must be declared before using the variable
(b) Tthey are local
(c) They are not initialised to zero
(d) They are global

6. Write one statement equivalent to the following two statements
x=sqr(a);
return(x);
Choose from one of the alternatives
(a) return(sqr(a));
(b) printf("sqr(a)");
(c) return(a*a*a);
(d) printf("%d",sqr(a));

7. Which of the following about the C comments is incorrect ?
(a) Ccommentscan go over multiple lines
(b) Comments can start any where in the line
(c) A line can contain comments with out any language statements
(d) Comments can occur within comments

8. What is the value of y in the following code?
x=7;
y=0;
if(x=6) y=7;
else y=1;
(a) 7
(b) 0
(c) 1
(d) 6

9. Read the function conv() given below
conv(int t){
int u;
u=5/9 * (t-32);
return(u);
}
What is returned
(a) 15
(b) 0
(c) 16.1
(d) 29

10. Which of the following represents true statement either x is in the range of 10 and 50 or y is zero
(a) x >= 10 && x <= 50 || y = = 0
(b) x<50
(c) y!=10 && x>=50
(d) None of these

11. Which of the following is not an infinite loop ?
(a) while(1)\{ ....}
(b) for(;;)
{
...
}
(c) x=0;
do{
/*x unaltered within the loop*/
.....}
while(x = = 0);
(d) # define TRUE 0
...
while(TRUE){
....}

12. What does the following function print?
func(int i)
{ if(i%2)return 0;
else return 1;}
main()
{
int =3;
i=func(i);
i=func(i);
printf("%d",i);
}
(a) 3
(b) 1
(c) 0
(d) 2

13. How does the C compiler interpret the following two statements
p=p+x;
q=q+y;
(a) p=p+x;
q=q+y
(b)p=p+xq=q+y
(c)p=p+xq;
q=q+y
(d)p=p+x/q=q+y

For questions 14,15,16,17 use the following alternatives
a.int
b.char
c.string
d.float
14. '9'
15. "1 e 02"
16. 10e05
17. 15

18. Read the folllowing code
# define MAX 100
# define MIN 100
....
....
if(x>MAX)
x=1;
else if(xx=-1;
x=50;
if the initial value of x=200,what is the value after executing this code?
(a) 200
(b) 1
(c) -1
(d) 50

19. A memory of 20 bytes is allocated to a string declared as char *s
then the following two statements are executed:
s="Entrance"
l=strlen(s);
what is the value of l ?
(a)20
(b)8
(c)9
(d)21

20. 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}

21. Consider the following structure:
struct num nam{
int no;
char name[25];
}
struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}};
.....
.....
printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1);
What does the above statement print?
(a) 8,9
(b) 9,9
(c) 8,8
(d) 8,unpredictable value

22. Identify the in correct expression
(a) a=b=3=4;
(b) a=b=c=d=0;
(c)float a=int b=3.5;
(d)int a; float b; a=b=3.5;

23. Regarding the scope of the varibles;identify the incorrect statement:
(a)automatic variables are automatically initialised to 0
(b)static variables are are automatically initialised to 0
(c)the address of a register variable is not accessiable
(d)static variables cannot be initialised with any expression

24. cond 1?cond 2?cond 3?:exp 1:exp 2:exp 3:exp 4;
is equivalent to which of the following?
(a)if cond 1
exp 1;
else if cond 2
exp 2;
else if cond 3
exp 3;
else exp 4;
(b) if cond 1
if cond 2
if cond 3
exp 1;
else exp 2;
else exp 3;
else exp 4;
(c) if cond 1 && cond 2 && cond 3
exp 1 |exp 2|exp 3|exp 4;
(d) if cond 3
exp 1;
else if cond 2 exp 2;
else if cond 3 exp 3;
else exp 4;

25. The operator for exponencation is
(a) **
(b) ^
(c) %
(d) not available

26. Which of the following is invalid
(a) a+=b
(b) a*=b
(c) a>>=b
(d) a**=b

27. What is y value of the code if input x=10
y=5;
if (x==10)
else if(x==9)
else y=8;
(a)9
(b)8
(c)6
(d)7

28. What does the following code do?
fn(int n,int p,int r){
static int a=p;
switch(n){
case 4:a+=a*r;
case 3:a+=a*r;
case 2:a+=a*r;
case 1:a+=a*r;}}
(a)computes simple interest for one year
(b)computes amount on compound interest for 1 to 4 years
(c)computes simple interest for four year
(d)computes compound interst for 1 year

29. a=0;
while(a<5)
printf("%d\\n",a++);
How many times does the loop occurs?
(a)infinite
(b)5
(c)4
(d)6

30. How many times does the loop iterated ?
for (i=0;i=10;i+=2)
printf("Hi\\n");
(a)10
(b) 2
(c) 5
(d) None of these

31. What is incorrect among the following
A recursive function
(a) calls itself
(b) is equivalent to a loop
(c) has a termination condition
(d) does not have a return value at all

32. Which of the following go out of the loop if expn 2 becoming false
(a) while(expn 1)\{...if(expn 2)continue;}
(b) while(!expn 1)\{if(expn 2)continue;...}
(c) do{..if(expn 1)continue;..}while(expn 2);
(d) while(!expn 2)\{if(expn 1)continue;..\}

33. Consider the following program
main()
{unsigned int i=10;
while(i>=0){
printf("%u",i)
i--;}
}
How many times the loop will get executed
(a)10
(b)9
(c)11
(d)infinite

34.Pick out the add one out
(a) malloc()
(b) calloc()
(c) free()
(d) realloc()

35.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

36. # 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

37.Consider the following program segment
int n,sum=1;
switch(n){
case 2:sum=sum+2;
case 3:sum*=2;
break;
default:sum=0;}
If n=2, what is the value of sum
(a) 0
(b) 6
(c) 3
(d) None of these

38. Identify the incorrect one
1.if(c=1)
2.if(c!=3)
3.if(a4.if(c==1)
(a) 1 only
(b) 1&3
(c) 3 only
(d) All of the above

39. The format specified for hexa decimal is
(a) %d
(b) %o
(c) %x
(d) %u

40. Find the output of the following program
main(){
int x=5, *p;
p=&x
printf("%d",++*p);
}
(a) 5
(b) 6
(c) 0
(d) none of these

41.Consider the following C code
main(){
int i=3,x;
while(i>0){
x=func(i);
i--; }
int func(int n){
static sum=0;
sum=sum+n;
return(sum);}
The final value of x is
(a) 6
(b) 8
(c) 1
(d) 3

43. Int *a[5] refers to
(a) array of pointers
(b) pointer to an array
(c) pointerto a pointer
(d) none of these

44.Which of the following statements is incorrect
(a) typedef struct new{
int n1;
char n2;
} DATA;
(b) typedef struct {
int n3;
char *n4;}ICE;
(c) typedef union{ int n5;
float n6;} UDT;
(d) #typedef union {
int n7;
float n8;} TUDAT;

TECHNICAL SECTION
Q1. typedef struct
{char *;
nodeptr next;
} * nodeptr ;

What does nodeptr stand for?
Q2. What does. int *x[](); means ?
Q3. struct list{
int x;
struct list *next;
}*head;

the struct head.x =100

Is the above assignment to pointer is correct or wrong ?
Ans. Wrong
Q4.What is the output of the following ?

int i;
i=1;
i=i+2*i++;
printf(%d,i);
Ans. 4
Q5. FILE *fp1,*fp2;

fp1=fopen("one","w")
fp2=fopen("one","w")
fputc('A',fp1)
fputc('B',fp2)
fclose(fp1)
fclose(fp2)
}

Find the Error, If Any?
Ans. no error. But It will over writes on same file.
What are the output(s) for the following ?
Q6. #include
char *f()
{char *s=malloc(8);
strcpy(s,"goodbye");
}

main()
{
char *f();
printf("%c",*f()='A'); }
Q7. #define MAN(x,y) (x)>(y)?(x):(y)
{int i=10;
j=5;
k=0;
k=MAX(i++,++j);
printf(%d %d %d %d,i,j,k);
}
Ans. 10 5 0
Q8. a=10;
b=5; c=3;
d=3;
if(a printf(%d %d %d %d a,b,c,d);
else
printf("%d %d %d %d a,b,c,d);
Q9. #include
show(int t,va_list ptr1)
{
int a,x,i;
a=va_arg(ptr1,int);
printf("\n %d",a);
}
display(char)
{
int x;
listptr;
va_star(otr,s);
n=va_arg(ptr,int);
show(x,ptr);
}

main()
{
display("hello",4,12,13,14,44);
}
Q10. main()
{
printf("hello");
fork();
}
Q11. main()
{
int i = 10;
printf(" %d %d %d \n", ++i, i++, ++i);
}
Q12. #include
main()
{
int *p, *c,i;
i = 5;
p = (int*) (malloc(sizeof(i)));
printf("\n%d",*p);
*p = 10;
printf("\n%d %d",i,*p);
c = (int*) calloc(2);
printf("\n%d\n",*c);
}
Q13. #define MAX(x,y) (x) >(y)?(x):(y)
main()
{
int i=10,j=5,k=0;
k= MAX(i++,++j);
printf("%d..%d..%d",i,j,k);
}
Q14.#include
main()
{
enum _tag{ left=10, right, front=100, back};
printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back);
}
Q15. main()
{
int a=10,b=20;
a>=5?b=100:b=200;
printf("%d\n",b);
}
Q16.#define PRINT(int) printf("int = %d ",int)
main()
{
int x,y,z;
x=03;y=02;z=01;
PRINT(x^x);
z<<=3;
PRINT(x);
y>>=3;
PRINT(y);
}
Q17. #include
main()
{
char s[] = "Bouquets and Brickbats";
printf("\n%c, ",*(&s[2]));
printf("%s, ",s+5);
printf("\n%s",s);
printf("\n%c",*(s+2));
}
Q18. main()
{
struct s1
{
char *str;
struct s1 *ptr;
};
static struct s1 arr[] = {
{"Hyderabad",arr+1},
{"Bangalore",arr+2},
{"Delhi",arr}
};
struct s1 *p[3];
int i;
for(i=0;i<=2;i++)
p[i] = arr[i].ptr;
printf("%s\n",(*p)->str);
printf("%s\n",(++*p)->str);
printf("%s\n",((*p)++)->str); }
Q19. .main()
{
char *p = "hello world!";
p[0] = 'H';
printf("%s",p);
}

0 comments: