Você está na página 1de 183

Wipro Candidate Experience

Interview process for freshers,written test Pattern 2012,aptitude questions pattern,essay writing topics,c
program asked in interview,career in wipro chennai,salary and training,wipro campus life as a freshers,of
campus experience, interview rounds,placement questions, WASIAN Experience

Search here

Search

Custom Search

Follow by Email

Email address...

Submit

5/28/2012

Part 5: FRP Dumps | C Puzzle | C++ Puzzle | DataStructure Puzzle

PART 1 PART 2 PART 3 PART 4 PART 5 PART 6 PART 7


Part 5:-

(23) What will be output if you will compile and execute the following c code?

void main(){

char *str;

scanf("%[^\n]",str);

printf("%s",str);

(a)It will accept a word as a string from user.

(b)It will accept a sentence as a string from user.

(c)It will accept a paragraph as a string from user.

(d)Compiler error

(e)None of above

Output: (b)
Explanation:

Task of % [^\t] is to take the stream of characters until it doesnt receive new

line character \t i.e. enter button of your keyboard.

General meaning of %[^ p]

String tutorial.

(24) What will be output if you will compile and execute the following c code?

void main(){

int a=5,b=10,c=15;

int *arr[]={&a,&b,&c};
printf("%d",*arr[1]);

(a)5

(b)10

(c)15

(d)Compiler error

(e)None of above

Output: (d)

Explanation:

Array element cannot be address of auto variable. It can be address of static or

extern variables.
What is auto variable?

What is extern variable?

What is static variable?

Array tutorial.

(25) What will be output if you will compile and execute the following c code?

void main(){

int array[3]={5};
int i;

for(i=0;i<=2;i++)

printf("%d ",array[i]);

(a)5 garbage garbage

(b)5 0 0

(c)5 null null

(d)Compiler error

(e)None of above

tput: (b)

Explanation:

Storage class of an array which initializes the element of the array at the time

of declaration is static. Default initial value of static integer is zero.


Properties of static storage class.

How to read complex array.

(26) What will be output if you will compile and execute the following c code?

void main(){

int array[2][2][3]={0,1,2,3,4,5,6,7,8,9,10,11};

printf("%d",array[1][0][2]);

}
(a)4

(b)5

(c)6

(d)7

(e)8

Output: 8
Explanation:

array[1][0][2] means 1*(2*3)+0*(3)+3=9th element of array starting from zero

i.e. 8.

Questions on two dimension array.

Complete tutorial of array.

(27) What will be output if you will compile and execute the following c code?

void main(){

int a[2][4]={3,6,9,12,15,18,21,24};

printf("%d %d %d",*(a[1]+2),*(*(a+1)+2),2[1[a]]);
}

(a)15 18 21

(b)21 21 21

(c)24 24 24

(d)Compiler error

(e)None of above
Output: (b)

Explanation:

In c,

a [1][2]

=*(a [1] +2)

=*(*(a+1) +2)

=2[a [1]]

=2[1[a]]

Now, a [1] [2] means 1*(4) +2=6th element of an array staring from zero i.e. 21.
Concept of complex array.

Concept of complex pointer.

Concept of complex function.

(28) What will be output if you will compile and execute the following c code?

void call(int,int,int);

void main(){

int a=10;

call(a,a++,++a);

void call(int x,int y,int z){


printf("%d %d %d",x,y,z);

(a)10 10 12

(b)12 11 11

(c)12 12 12

(d)10 11 12

(e)Compiler error

Output: (b)

Explanation:
Default parameter passing scheme of c is cdecl i.e. argument of function will

pass from right to left direction.

First ++a will pass and a=11

Then a++ will pass and a=11

Then a will pass and a=12

What is pascal and cedecl parameter passing scheme?

Concept of variable numbers of argument.


(29) What will be output if you will compile and execute the following c code?

void main(){

int x=5,y=10,z=15;

printf("%d %d %d");

(a)Garbage Garbage Garbage

(b)5 10 15

(c)15 10 5

(d)Compiler error
(e)Run time error

Output: (c)

Explanation:

Auto variables are stored in stack as shown in following figure.


Stack follow LIFO data structure i.e. last come and first out. First %d will

print then content of two continuous bytes from the top of the stack and so on.

Memory map tutorial.

More questions based on memory map.

(30) What will be output if you will compile and execute the following c code?

void main(){

register int i,x;

scanf("%d",&i);

x=++i + ++i + ++i;


printf("%d",x);

(a)17

(b)18

(c)21

(d)22

(e)Compiler error
Output: (e)

Explanation:

In c register variable stores in CPU it doesnt store in RAM. So register

variable have not any memory address. So it is illegal to write &a.

Complete tutorial of storage class with examples.

Properties of register storage class.

(31) What will be output if you will compile and execute the following c code?

void main(){
int a=5;

int b=10;

int a=2;

a++;

b++;

printf("%d %d",a,b);

(a)5 10

(b)6 11

(c)5 11

(d)6 10

(e)Compiler error
Output: (c)

Explanation:

Default storage class of local variable is auto. Scope and visibility of auto

variable is within the block in which it has declared. In c, if there are two

variables of the same name then we can access only local variable. Hence inside

the inner block variable a is local variable which has declared and defined

inside that block. When control comes out of the inner block local variable a

became dead.

Complete tutorial of storage class with examples.

What is auto storage class?


(32) What will be output if you will compile and execute the following c code?

void main(){

float f=3.4e39;

printf("%f",f);

(a)3.4e39

(b)3.40000

(c)+INF

(d)Compiler error

(e)Run time error


Output: (c)

Explanation:

If you will assign value beyond the range of float data type to the float

variable it will not show any compiler error. It will store infinity.

Data type tutorial with examples.

Concept of float data type.


(33) What will be output if you will compile and execute the following c code?

void main(){

enum color{

RED,GREEN=-20,BLUE,YELLOW

};

enum color x;

x=YELLOW;

printf("%d",x);

(a)-22

(b)-18

(c)1
(d)Compiler error

(e)None of above

Output: (b)

Explanation:

Default value of enum constant = value of previous enum constant +1

Default value of first enum constant=0

Hence:

BLUE=GREEN+1=-20+1=-19
YELLOW=BLUE+1=-19+1=-18

Complete tutorial of enum data type with examples.

(34) What will be output if you will compile and execute the following c code?

void main(){

asm{

mov bx,8;

mov cx,10

add bx,cx;

}
printf("%d",_BX);

(a)18

(b)8

(c)0

(d)Compiler error

(e)None of above
Output: (a)

Explanation:

asm keyword is used to write assembly language program in c. mov command stores

the constants in the register bx, cx etc. add command stores the content of

register and stores in first register i.e. in bx.

How to write assembly language program by c?

Advance c tutorial.

(35) What will be output if you will compile and execute the following c code?
void main(){

enum xxx{

a,b,c=32767,d,e

};

printf("%d",b);

(a)0

(b)1

(c)32766

(d)Compiler error

(e)None of above
Output: (d)

Explanation:

Size of enum constant is size of sign int. Since value of c=32767. Hence value

of d will be 32767+1=32768 which is beyond the range of enum constant.

Tutorial of data type with examples.

(36) What will be output if you will compile and execute the following c code?
void main(){

signed int a=-1;

unsigned int b=-1;

if(a==b)

printf("%d %d",a,b);

else

printf("Not equal");

(a)-1 -1

(b)-1 32767

(c)-1 -32768
(d)Not equal

(e)Compiler error

Output: (a)

Explanation:

What is automatic type conversion?


(37) What will be output if you will compile and execute the following c code?

void main(){

float f=5.5f;

float x;

x=f%2;

printf("%f",x);

(a)1.500000

(b)1.000000

(c)5.500000

(d)Compiler error
(e)None of above

Output: (d)

Explanation:

Modular division is not allowed with floating number.

Properties of modular division.


Operators tutorial with examples.

(38) What will be output if you will compile and execute the following c code?

void main(){

int a=-20;

int b=-3;

printf("%d",a%b);

(a)2

(b)-2

(c)18
(d)-18

(e)Compiler error

Output: (b)

Explanation:

Sign of resultant of modular division depends upon only the sign of first

operand.

Properties of modular division.

Operators tutorial with examples.


(39) What will be output if you will compile and execute the following c code?

void main(){

char c='0';

printf("%d %d",sizeof(c),sizeof('0'));

(a)1 1

(b)2 2

(c)1 2

(d)2 1
(e)None of above

Output: (c)

Explanation:

Size of char data type is one byte while size of character constant is two byte.

Why character constant is of two byte in c?


(40) What will be output if you will compile and execute the following c code?

void main(){

char *url="c:\tc\bin\rw.c";

printf("%s",url);

(a)c:\tc\bin\rw.c

(b)c:/tc/bin/rw.c

(c)c: c inw.c

(d)c:cinw.c

(e)w.c in
Output: (e)

Explanation:

1. \t is tab character which moves the cursor 8 space right.

2. \b is back space character which moves the cursor one space back.

3. \r is carriage return character which moves the cursor beginning of the line.
Complete string tutorial with examples.

Properties of escape characters.

(41) What will be output if you will compile and execute the following c code?

void main(){

clrscr();

goto abc;

printf("main");
getch();

void dispaly(){

abc

printf("display");

(a)main

(b)display

(c)maindisplay

(d)displaymain

(e)Compiler error
Output: (e)

Explanation:

Label of goto cannot be in other function because control cannot move from one

function to another function directly otherwise it will show compiler error:

unreachable label

What is goto keyword.

Complete function tutorial with examples.

(42) What will be output if you will compile and execute the following c code?
void main(){

int i=3;

if(3==i)

printf("%d",i<<2<<1);

else

printf("Not equal");

(a)1

(b)48

(c)24
(d)Not equal

(e)Compiler error

Output: (c)

Explanation:

Associative of bitwise left shifting operator is left to right. In the following

expression:

i<<2<<1

There are two bitwise operators. From rule of associative leftmost operator will

execute first.
i <<><<>

After execution of leftmost bitwise left shifting operator:

so i=i*pow(2,2)

=3*

What is associative?

What is precedence?

Tutorial of bitwise operators.

(43) What will be output if you will compile and execute the following c code?
void main(){

int x=2,y=3;

if(x+y<=5)

printf("True");

else

printf("False");

(a)True

(b)False

(c)Compiler error: Lvalued required

(d)Compiler error: Invalid expression


(e)None of above

Output: (a)

Explanation:

Expression x+y<=5

=> 2+3 <=5

=> 5<=5 is true because 5 is either greater than 5 or equal to 5.


Operator tutorial with examples.

(44) What will be output if you will compile and execute the following c code?

void main(){

const int i=5;

i++;

printf("%d",i);

(a)5

(b)6

(c)0
(d)Compiler error

(e)None of above

Output: (d)

Explanation:

We cannot modify the const variable by using increment operator.

Properties of const keyword.


Properties of volatile keyword.

Data type tutorial with examples.

(45) What will be output if you will compile and execute the following c code?

void main(){

const int x=25;

int * const p=&x;

*p=2*x;

printf("%d",x);

}
(a)25

(b)50

(c)0

(d)Compiler error

(e)None of above

Output: (b)
Explanation:

const keyword in c doesnt make any variable as constant but it only makes the

variable as read only. With the help of pointer we can modify the const

variable. In this example pointer p is pointing to address of variable x. In the

following line:

int * const p=&x;

p is constant pointer while content of p i.e. *p is not constant.

*p=2*x put the value 50 at the memory location of variable x.

Properties of const keyword.

What is constant pointer?

Data type tutorial with examples.


(46) What will be output if you will compile and execute the following c code?

void main(){

int i=11;

int const * p=&i;

p++;

printf("%d",*p);

(a)11

(b) 12

(c)Garbage value
(d)Compiler error

(e)None of above

Output: (c)

Explanation:

In the following line:

int const * p=&i;

*p i.e. content of p is constant pointer p is not constant pointer. So we can

modify the pointer p. After incrementing the pointer it will point next memory
location and its content will any garbage value.

Note: We have assumed arbitrary memory address.

To make pointer p as constant pointer write:

int const * const p=&i;

Properties of const keyword.

Properties of volatile keyword.


(47) What will be output if you will compile and execute the following c code?

void main(){

int a=15,b=10,c=5;

if(a>b>c )

printf("Trre");

else

printf("False");

}
(a)True

(b)False

(c)Run time error

(d)Compiler error

(e)None of above

Output: (b)

Explanation:
Relation operator in c always returns 1 when condition is true and 0 when

condition is false. So in the following expression

a>b>c

Associative of relational operators are left to right order of execution will be

following manner:

Hence in this expression first solve bolded condition: a > b > c

Since condition a>b is true so result will be 1. Now expression became:

1>c
Since this condition is false so result will be 0. Thus else part will execute.

What is associative?

What is precedence?

(48) What will be output if you will compile and execute the following c code?

void main(){

float f;

f=3/2;

printf("%f",f);

}
(a)1.5

(b)1.500000

(c)1.000000

(d)Compiler error

(e)None of above

Output: (c)

Explanation:

In the following expression:

f=3/2 both 3 and 2 are integer constant hence its result will also be an integer

constant i.e. 1.

Properties of floating type numbers.


(49) What will be output if you will compile and execute the following c code?

void main(){

int a=sizeof(a);

a=modify(a);

printf("%d",a);

int modify(int x){

int y=3;

_AX=x+y;

return;

(a)2

(b)3
(c)5

(d)Garbage value

(e)None of above

Output: (c)

Explanation:

_AX is register pseudo variable. It stores return type of function.


What is register pseudo variable?

What is global identifier?

(50) What will be output if you will compile and execute the following c code?

#define PRINT printf("c");printf("c++");

void main(){

float a=5.5;

if(a==5.5)

PRINT

else

printf("Not equal");
}

(a)c c++

(b)Not equal

(c)c

c++

(d)Compiler error

(e)None of above

Output: (d)
Explanation:

First see intermediate file:

try.c 1:

try.c 2: void main(){

try.c 3: float a=5.5;

try.c 4: if(a==5.5)

try.c 5: printf("c");printf("c++");

try.c 6: else

try.c 7: printf("Not equal");

try.c 8: }

try.c 9:
try.c 10:

If there are more than one statement in if block then it is necessary to write

inside the { } otherwise it will show compiler error: misplaced else

More questions on preprocessors.

Preprocessor tutorial with examples.

Links to this post

2 comments

C questions and answer


(51) What will be output if you will compile and execute the following c code?

struct marks{

int p:3;

int c:3;

int m:2;

};

void main(){
struct marks s={2,-6,5};

printf("%d %d %d",s.p,s.c,s.m);

(a) 2 -6 5

(b) 2 -6 1

(c) 2 2 1

(d) Compiler error

(e) None of these

Answer: (c)

Explanation:

Binary value of 2: 00000010 (Select three two bit)

Binary value of 6: 00000110

Binary value of -6: 11111001+1=11111010


(Select last three bit)

Binary value of 5: 00000101 (Select last two bit)

Complete memory representation:

Structure tutorial

More questions

(52) What will be output if you will compile and execute the following c code?

void main(){

static char *s[3]={"math","phy","che"};

typedef char *( *ppp)[3];


static ppp p1=&s,p2=&s,p3=&s;

char * (*(*array[3]))[3]={&p1,&p2,&p3};

char * (*(*(*ptr)[3]))[3]=&array;

p2+=1;

p3+=2;

printf("%s",(***ptr[0])[2]);

(a) math

(b) phy

(c) che
(d) Compiler error

(e) None of these

Answer: (c)

Explanation:

Here

ptr: is pointer to array of pointer to string.

P1, p2, p3: are pointers to array of string.


array[3]: is array which contain pointer to array of string.

Pictorial representation:

Note: In the above figure upper part of box represent content and lower part

represent memory address. We have assumed arbitrary address.

As we know p[i]=*(p+i)

(***ptr[0])[2]=(*(***ptr+0))[2]=(***ptr)[2]

=(***(&array))[2] //ptr=&array

=(**array)[2] //From rule *&p=p


=(**(&p1))[2] //array=&p1

=(*p1)[2]

=(*&s)[2] //p1=&s

=s[2]=che

How to read complex pointer?

Pointer tutorial.

(53) What will be output if you will compile and execute the following c code?

#include"conio.h"
int display();

int(*array[3])();

int(*(*ptr)[3])();

void main(){

array[0]=display;

array[1]=getch;

ptr=&array;

printf("%d",(**ptr)());

(*(*ptr+1))();

int display(){

int x=5;

return x++;
}

(a)5

(b)6

(c)0

(d)Compiler error

(e)None of these
Answer: (a)

Explanation:

In this example:

array []: It is array of pointer to such function which parameter is void and

return type is int data type.

ptr: It is pointer to array which contents are pointer to such function which

parameter is void and return type is int type data.

(**ptr)() = (** (&array)) () //ptr=&array

= (*array) () // from rule *&p=p

=array [0] () //from rule *(p+i)=p[i]

=display () //array[0]=display
(*(*ptr+1))() =(*(*&array+1))() //ptr=&array

=*(array+1) () // from rule *&p=p

=array [1] () //from rule *(p+i)=p[i]

=getch () //array[1]=getch

How to read complex array?

Array tutorial.

(54) What will be output if you will compile and execute the following c code?

void main(){
int i;

char far *ptr=(char *)0XB8000000;

*ptr='A';

*(ptr+1)=1;

*(ptr+2)='B';

*(ptr+3)=2;

*(ptr+4)='C';

*(ptr+5)=4;

}
Answer:

It output will be A, B and C in blue, green and red color respectively. As shown

in following figure:

What is far pointer?

Advance c tutorial?
Working with text video memory.

(55) What will be output if you will compile and execute the following c code?

#include "dos.h"

void main(){

int j;

union REGS i,o;

char far *ptr=(char *)0XA0000000;

i.h.ah=0;

i.h.al=0x13;

int86(0x10,&i,&o);
for(j=1;j<=100;j++){

*(ptr+j)=4;

Answer:

One red color line in the graphics console as shown in the following figure
What is union REGS?

Advance c tutorial.

Working with graphics video memory.


(56) What will be output if you will compile and execute the following c code?

void main(){

int huge*p=(int huge*)0XC0563331;

int huge*q=(int huge*)0xC2551341;

*p=200;

printf("%d",*q);

(a)0

(b)Garbage value

(c)null
(d) 200

(e)Compiler error

Answer: (d)

Explanation:

Physical address of huge pointer p


Huge address: 0XC0563331

Ofset address: 0x3331

Segment address: 0XC056

Physical address= Segment address * 0X10 + Ofset address

=0XC056 * 0X10 +0X3331

=0XC0560 + 0X3331

=0XC3891

Physical address of huge pointer q

Huge address: 0XC2551341


Ofset address: 0x1341

Segment address: 0XC255

Physical address= Segment address * 0X10 + Ofset address

=0XC255 * 0X10 +0X1341

=0XC2550 + 0X1341

=0XC3891

Since both huge pointers p and q are pointing same physical address so content

of q will also same as content of q.

What is huge pointer?


Pointer tutorial.

(57) Write c program which display mouse pointer and position of pointer.(In x

coordinate, y coordinate)?

Answer:

#includedos.h

#includestdio.h

void main()

{
union REGS i,o;

int x,y,k;

//show mouse pointer

i.x.ax=1;

int86(0x33,&i,&o);

while(!kbhit()) //its value will false when we hit key in the key board

i.x.ax=3; //get mouse position

x=o.x.cx;

y=o.x.dx;

clrscr();

printf("(%d , %d)",x,y);
delay(250);

int86(0x33,&i,&o);

getch();

What is int86?

Advance c tutorial.

(58) Write a c program to create dos command: dir.

Answer:
Step 1: Write following code.

#include stdio.h

#include dos.h

void main(int count,char *argv[])

struct find_t q ;

int a;

if(count==1)

argv[1]="*.*";

a = _dos_findfirst(argv[1],1,&q);

if(a==0)
{

while (!a)

printf(" %s\n", q.name);

a = _dos_findnext(&q);

else

printf("File not found");

}
Step 2: Save the as list.c (You can give any name)

Step 3: Compile and execute the file.

Step 4: Write click on My computer of Window XP operating system and select

properties.

Step 5: Select Advanced -> Environment Variables

Step 6: You will find following window:

Click on new button (Button inside the red box)

Step 7: Write following:

Variable name: path


Variable value: c:\tc\bin\list.c (Path where you have saved)

Step 8: Open command prompt and write list and press enter.

Command line argument tutorial.

(59) What will be output if you will compile and execute the following c code?

void main(){
int i=10;

static int x=i;

if(x==i)

printf("Equal");

else if(x>i)

printf("Greater than");

else

printf("Less than");

(a) Equal

(b) Greater than

(c) Less than


(d) Compiler error

(e) None of above

Answer: (d)

Explanation:

static variables are load time entity while auto variables are run time entity.

We can not initialize any load time variable by the run time variable.

In this example i is run time variable while x is load time variable.


Properties of static variables.

Properties of auto variables.

(60) What will be output if you will compile and execute the following c code?

void main(){

int i;

float a=5.2;

char *ptr;

ptr=(char *)&a;

for(i=0;i<=3;i++)

printf("%d ",*ptr++);
}

(a)0 0 0 0

(b)Garbage Garbage Garbage Garbage

(c)102 56 -80 32

(d)102 102 -90 64

(e)Compiler error
Answer: (d)

Explanation:

In c float data type is four byte data type while char pointer ptr can point one

byte of memory at a time.

Memory representation of float a=5.2

ptr pointer will point first fourth byte then third byte then second byte then

first byte.

Content of fourth byte:

Binary value=01100110
Decimal value= 64+32+4+2=102

Content of third byte:

Binary value=01100110

Decimal value=64+32+4+2=102

Content of second byte:

Binary value=10100110

Decimal value=-128+32+4+2=-90

Content of first byte:

Binary value=01000000

Decimal value=64

Note: Character pointer treats MSB bit of each byte i.e. left most bit of above

figure as sign bit.


How to represent float data type in memory?

(61) What will be output if you will compile and execute the following c code?

void main(){

int i;

double a=5.2;

char *ptr;

ptr=(char *)&a;

for(i=0;i<=7;i++)

printf("%d ",*ptr++);
}

(a) -51 -52 -52 -52 -52 -52 20 64

(b) 51 52 52 52 52 52 20 64

(c) Eight garbage values.

(d) Compiler error

(e) None of these


Answer: (a)

Explanation:

In c double data type is eight byte data type while char pointer ptr can point

one byte of memory at a time.

Memory representation of double a=5.2

ptr pointer will point first eighth byte then seventh byte then sixth byte then

fifth byte then fourth byte then third byte then second byte then first byte as

shown in above figure.


Content of eighth byte:

Binary value=11001101

Decimal value= -128+64+8+4+1=-51

Content of seventh byte:

Binary value=11001100

Decimal value= -128+64+8+4=-52

Content of sixth byte:

Binary value=11001100

Decimal value= -128+64+8+4=-52

Content of fifth byte:

Binary value=11001100

Decimal value= -128+64+8+4=-52


Content of fourth byte:

Binary value=11001100

Decimal value= -128+64+8+4=-52

Content of third byte:

Binary value=11001100

Decimal value= -128+64+8+4=-52

Content of second byte:

Binary value=000010100

Decimal value=16+4=20

Content of first byte:

Binary value=01000000

Decimal value=64
Note: Character pointer treats MSB bit of each byte i.e. left most bit of above

figure as sign bit.

How to represent double data type in memory?

(62) What will be output if you will compile and execute the following c code?

void main(){

printf("%s","c" "question" "bank");

(a) c question bank

(b) c
(c) bank

(d) cquestionbank

(e) Compiler error

Answer: (d)

Explanation:

In c string constant xy is same as x y


String tutorial.

(63) What will be output if you will compile and execute the following c code?

void main(){

printf("%s",__DATE__);

(a) Current system date

(b) Current system date with time

(c) null

(d) Compiler error


(e) None of these

Answer: (a)

Explanation:

__DATE__ is global identifier which returns current system date.

What is global identifier?


(64) What will be output if you will compile and execute the following c code?

void main(){

char *str="c-pointer";

printf("%*.*s",10,7,str);

(a) c-pointer

(b) c-pointer

(c) c-point

(d) cpointer null null

(e) c-point
Answer: (e)

Explanation:

Meaning of %*.*s in the printf function:

First * indicates the width i.e. how many spaces will take to print the string

and second * indicates how many characters will print of any string.
Following figure illustrates output of above code:

Properties of printf function.

(65) What will be output if you will compile and execute the following c code?

void start();

void end();

#pragma startup start


#pragma exit end

int static i;

void main(){

printf("\nmain function: %d",++i);

void start(){

clrscr();

printf("\nstart function: %d",++i);

void end(){

printf("\nend function: %d",++i);

getch();

}
(a)

main function: 2

start function: 1

end function:3

(b)

start function: 1

main function: 2

end function:3

(c)
main function: 2

end function:3

start function: 1

(d) Compiler error

(e) None of these


Answer: (b)

Explanation:

Every c program start with main function and terminate with null statement. But

#pragma startup can call function just before main function and #pragma exit

What is pragma directive?

Preprocessor tutorial.

(66) What will be output if you will compile and execute the following c code?

void main(){

int a=-12;
a=a>>3;

printf("%d",a);

(a) -4

(b) -3

(c) -2

(d) -96

(e) Compiler error


Answer :( c)

Explanation:

Binary value of 12 is: 00000000 00001100

Binary value of -12 wills 2s complement of 12 i.e.

So binary value of -12 is: 11111111 11110100


Right shifting rule:

Rule 1: If number is positive the fill vacant spaces in the left side by 0.

Rule 2: If number is negative the fill vacant spaces in the left side by 1.

In this case number is negative. So right shift all the binary digits by three

space and fill vacant space by 1 as shown following figure:


Since it is negative number so output will also a negative number but its 2s

complement.

Hence final out put will be:

And its decimal value is: 2

Hence output will be:-2


More questions on shifting operator.

Operator tutorial.

(67) What will be output if you will compile and execute the following c code?

#include "string.h"

void main(){

clrscr();

printf("%d %d",sizeof("string"),strlen("string"));

getch();
}

(a) 6 6

(b) 7 7

(c) 6 7

(d) 7 6

(e) None of these


Answer: (d)

Explanation:

Sizeof operator returns the size of string including null character while strlen

function returns length of a string excluding null character.

String tutorial.

Library functions of string.

(68) What will be output if you will compile and execute the following c code?

void main(){

static main;
int x;

x=call(main);

clrscr();

printf("%d ",x);

getch();

int call(int address){

address++;

return address;

(a) 0

(b) 1

(c) Garbage value

(d) Compiler error

(e) None of these


Answer: (b)

Explanation:

As we know main is not keyword of c but is special type of function. Word main

can be name variable in the main and other functions.

What is main function in c?


(69) What will be output if you will compile and execute the following c code?

void main(){

int a,b;

a=1,3,15;

b=(2,4,6);

clrscr();

printf("%d ",a+b);

getch();

(a) 3
(b) 21

(c) 17

(d) 7

(e) Compiler error

Answer: (d)

Explanation:

In c comma behaves as separator as well as operator.


a=1, 3, 15;

b= (2, 4, 6);

In the above two statements comma is working as operator. Comma enjoys least

precedence and associative is left to right.

Assigning the priority of each operator in the first statement:

Hence 1 will assign to a.

Assigning the priority of each operator in the second statement:


Operator tutorial.
(70) What will be output if you will compile and execute the following c code?

int dynamic(int,...);

void main(){

int x,y;

x=dynamic(2,4,6,8,10,12,14);

y=dynamic(3,6,9,12);

clrscr();

printf("%d %d ",x,y);

getch();

int dynamic(int s,...){


void *ptr;

ptr=...;

(int *)ptr+=2;

s=*(int *)ptr;

return s;

(a) 8 12

(b) 14 12

(c) 2 3

(d) Compiler error

(e) None of these


Answer: (a)

Explanation:

In c three continuous dots is known as ellipsis which is variable number of

arguments of function. In this example ptr is generic pointer which is pointing

to first element of variable number of argument. After incrementing it will

point third element.

What is variable number of argument?


(71) What will be output if you will compile and execute the following c code?

int extern x;

void main()

printf("%d",x);

x=2;

getch();

int x=23;

(a) 0
(b) 2

(c) 23

(d) Compiler error

(e) None of these

Answer: (c)

Explanation:

extern variables can search the declaration of variable any where in the
program.

Properties of extern storage class.

(72) What will be output if you will compile and execute the following c code?

void main(){

int i=0;

if(i==0){

i=((5,(i=3)),i=1);

printf("%d",i);

else
printf("equal");

(a) 5

(b) 3

(c) 1

(d) equal

(e) None of above


Answer: (c)

Explanation:

Comma operator.

Operator tutorial.

(73) What will be output if you will compile and execute the following c code?

void main(){

int a=25;

clrscr();
printf("%o %x",a,a);

getch();

(a) 25 25

(b) 025 0x25

(c) 12 42

(d) 31 19

(e) None of these


Answer: (d)

Explanation:

%o is used to print the number in octal number format.

%x is used to print the number in hexadecimal number format.

Note: In c octal number starts with 0 and hexadecimal number starts with 0x.

What is octal number?

What is hexadecimal number?


(74) What will be output if you will compile and execute the following c code?

#define message "union is\

power of c"

void main(){

clrscr();

printf("%s",message);

getch();

}
(a) union is power of c

(b) union ispower of c

(c) union is

Power of c

(d) Compiler error

(e) None of these

Answer: (b)
Explanation:

If you want to write macro constant in new line the end with the character \.

Preprocessor tutorial.

(75) What will be output if you will compile and execute the following c code?

#define call(x) #x

void main(){

printf("%s",call(c/c++));

}
(a)c

(b)c++

(c)#c/c++

(d)c/c++

(e)Compiler error

Answer: (d)
Explanation:

# is string operator. It converts the macro function call argument in the

string. First see the intermediate file:

test.c 1:

test.c 2: void main(){

test.c 3: printf("%s","c/c++");

test.c 4: }

test.c 5:

It is clear macro call is replaced by its argument in the string format.

What is # and ##?


Preprocessor tutorial?

(75) What will be output if you will compile and execute the following c code?

void main(){

if(printf("cquestionbank"))

printf("I know c");

else

printf("I know c++");

}
(a) I know c

(b) I know c++

(c) cquestionbankI know c

(d) cquestionbankI know c++

(e) Compiler error

Answer: (c)

Explanation:

Return type of printf function is integer which returns number of character it


prints including blank spaces. So printf function inside if condition will

return 13. In if condition any non- zero number means true so else part will not

execute.

Prototype of printf function.

1. Which of the following does not have an unary operator?

1) -7 2) ++i

3) j 4) all of the above

2. In printf(),the appearance of the output of the output can be afected by

1) field with 2) conversion character

3) flag 4) all of the above


3. Any of the following programs in c has access to three standard files:

1) standard input file, standard output file, standard error file

2) stdin,stdout, stderr

3) keyboard,screen,screen

4) all the above

5) A variable can be declared static using the keyword.

1) extern 2) static

3) stat 4) auto

6) A program can be terminated at any time by calling the function

1) fflush() 2) ferror()

3) exit() 4) clearerr()

7) Heap

1) is a region from where memory is allocated

2) lies between you program and the stack

3) is a finite area

4) all of the above


8) A function can

1) perform a task 2) return a value

3) change value of actual arguments in call by reference

4) all of the above

9) Function definition void check(int i ,char*j) is

1) call by value 2)call by reference

3) both (1) and (2) 4)in valid function definition

10) A union consists of a number of elements that

1) all occupy the same space in memory

2) must be structure

3) are grouped next to each other in memory

4) all have the same type

11) Which of the following array is defined in the statements

Char name[30]?

1) name is one dimensiona,30-element integer array


2) name is one dimensional,30-element floating point array

3) name is one dimensional ,30-element character array

4) name is one dimensional,30-elements string array

12) c program contains the following declaration:

Static float table[2][3]={ {1.1,1.2,1.3},

{2.1,2.2,2.3}

};

What is the value of *(*(table+1)+1)?

1) 2.2 2) 1.2

3) 2.1 4) 2.3

13) A c program contains the following declarations and initial

Assignments:

int i=8,j=5; float x=0.0005,y=-0.01;

Char c=c,d=d;

What would be the value of the following expression?

(3*i-2*j)%(2*d-3)

1)14 2)18
3) 1 4) 0

14) The declaration : int f(int); means

1) f accepts an integer argument and returns an integer quantity

2) f accepts two arguments and returns a double precision quantity, and the second is an integer

3) f accepts three arguments and returns nothing. The first arguments

is a double-precision quantity, and the second is an integer

4) f does not accepts any arguments but returns a single character

16) The arguments of a function are included between

1) The parenthesis 2) double quotes

3) curly braces 4) #

17) The int type of constraints are whole numbers in the range

1) -23677 to 23678 2) -32768 to 32767

3) -32767 to 32768 4) -32864 to 32864

18) If the variables i,j and k are assigned the values 5,3 and 2 respectively, then the expression i=j+(k++
=6)+7;

1) gives an error message 2) assigns a value 16 to i

3) assigns a value 18 to i 4) assigns a value 19 to i


19) In a relational expression involving characters, we actually

Compare

1) the ASCII codes of the characters

2) the characters themselves

3) neither of the two

4) binary code and hexadecimal code

21) The word case used in the switch statement represents a

1) function in the c language

2) data type in the c language

3) keyword in the c language

4) global variable in the c language

22)The logical NOT operator represented by ! is a

1) unary operator 2) binary operator

3) ternary operator 4) octal operator

23) The statement : scanf(%d,&i);


1) assigns an integer to the variable i

2) gives an error message;

3) does not assign any value to i

4) assigns an float to the variable i

24) A pointer is declared by using a statement such as

1) int *p; 2) point; 3) pointer *p; 4) int &p;

25)The null character is represented by

1) \n 2)\0 3)\o 4)\t

26) The members in the union

1) have diferent memory locations

2) share the memory with a structure

3) have the same memory location

4) have diferent memory variable

27) The global variables by default belong to

1) the register type 2) the static type


3) the auto type 4) the dynamic type

28) The bit fields are the members of a/an

1) array 2) structure 3) union 4) both 2 and 3

29) In c, square brackets [ ] are used in

1) functions 2) arrays 3) statements 4) all of the above

30) A fields width specifier in a printf() function

1) specifies the maximum value of a number

2) controls the size of type used to print numbers

3) controls the merging of the program listing

4) specifies how many characters positions will be used for a number

31) The two operators && and || are

1) arithmetic operators 2) equality operators


3) logical operators 4) relational operators

32) The library files that come with c are

1) text editor for program development

2) the compiler and liker

3) program examples

4) files that contain functions which carry out various commonly Used operations and calculations

33) Precedence determines which operator

1) is evaluated first 2) is most important

3) is fastest 4) operates on the largest number

37) The malloc() function

1) returns a pointer to the allocated memory

2) returns a pointer to the first byte of region of memory

3) changes the size of the allocated memory

4) deallocates the memory

38) which of the following expressions will return a 1 if both bits have A value of 1; otherwise will return
a value of 0?
1) AND 2)OR 3)XOR 4)1stderr complement

39) If an error occurs while opening a file the file pointer is assigned a value

1) NULL 2) stdout 3) sstderr 4) not defined

40) Which of the following backslash codes used for bell?

1) \b 2) \a 3) \r 4) \s

41) One is not the valid keywords in the c language is

1) printf 2) CHAR 3) auto 4) scanf

42) The comments in a c language program are placed between

1) \* and /* 2) / and .* 3) /*and*/ 4) # and #

43) If p and q are assigned the values 2 and 3 respectively then the statement p=q++

1) gives an error message 2) assigns a value 4 to p

3) assigns a value 3 to p 4) assigns a value 5 to p


44) A compound statement is a group of statement included between a pair of

1) double quots 2) curly braces

3) parentesis 4) / and/

45) The number of the relational operators in the c language is

1) four 2) six 3) three 4)one

46) In the c language, 3 represents

1) a digit 2)an integer 3)a character 4)a word

47) In the c language, a hexadecimal number is represented by writing

1) x 2) xo 3) 0x 4)h

48) A string in the c language is represented by enclosing a series of characters in

1) single quotes 2) double quotes

3) parenthesis 4) / and /

49) One structure can be


1) a member of some other structure

2) a member of the same structure

3) a member of a union

4) all of the above

51) Almost every c program begins with the statement

1) main() 2) printf() 3) #include<stdio.h> 4) scanf()

52) A single character input from the keyboard can be obtained by using the function

1) printf( ) 2) getchar( ) 3) putchar( ) 4) scanf( )

53) An expression

1) is a collection of data objects and operators that can be evaluated to a single value

2) is a name that substitutes for a sequence of characters

3) causes the computer to carry out some action

4) all of the above


54) The expression c=i++ causes

1) the value of I assigned to c and then I incremented by 1

2) I to be incremented by 1 and then the value of I assigned to @

3) Value of I assigned to c

4) I to be incremented by 1

55)The single character input/output functions are

1) scanf( ) and printf( ) 2) getchar( ) and printf( )

3) scanf( ) and putchar( ) 4) getchar( ) and putchar( )

56) The conversion character I for data output means that the

Data item is displayed as

1) a floating point value with an exponent

2) an unsigned decimal integer

3) a signed decimal integer

4) an octal integer

58) In a circular linked list


1) components are all linked together in some sequential manner

2) there is no beginning and no end

3) components are arranged hierarchically

4) forward and backward transversal within the list is permitted

60) A c function contain

1)function body 2)argument declaration

3)a function header 4)all of the above

C QUESTIONS ON ARRAYS

main()

Int a[5];

a[-2]=10;

a[2]=1;

printf(%d,-2[a]);

a) compilation error b)10 c)-1 d)none of the above

Ans c

main()

Char a[3][3]={{a,b,c},pqr,xy};
Printf(%s\n,&a[0][0]);

a) a b)compilation error c)abcpqrxy d)abc

Ans c

main()

char a[3][3]={abc,pqr,xyz};

printf(%c,a[2][2]);

a) q b) r c) z d) compilation error

Ans c

4) main()

Char a[100]={abcdef};

a++;

printf(%s,&a[1]);

a) bcdef b) abcdef c)compilation error d) none of the above

Ans c
5) main()

Char *p=algc;

Printf(%c,++*(p++));

Printf(%c,*++p);

a) al b) bg c) lg d) none of the above

ans b

6) main()

Int n[25];

n[0]=100;

n[24]=200;

printf(%d%d,*n,*(n+24)+*(n+0));

a) 100 200 b) 100 300 c) 0,100 d) 0,200

Ans b

7)main()

Int a[3]={1};
Printf(%d,a[1]);

a) 1 b) 0 c) compillation error d) none of the above

Ans b

8) main()

Static int n[3][3]={2,4,3,6,8,5,3,5,1};

Printf(%d%d%d,n[2][1],n[1][1],n[3][1]);

a)5 8 garbage value b) 845 c)623 d)825

ans a)

9) main()

Char a=ab;

Printf(%c,a);

a) a b) b c) ab d) error

ans a)
10) main()

Char *p;

p=%d\n;

p[1]=c;

printf(p,65);

a) A b) c c) 65 d) error

ans a

11) main()

int a=1;

switch(a==5)

Case 1: pf(hi);

Break;

Case 0:pf(hello);break;

Default : pf(wipro\n);

a) Hi b)hello c) hi d)wipro
Ans: b

12) main()

Char a[]={\012345\};

Printf(%s %d %d\n,a,sizeof(a),sizeof(*a));

13) main()

Char a[]=hell0009;

Printf(%s\n,a);

Ans:: hell0009

DATA STRUCTURES ON SINGLE LINKED LIST

1) each structure in a single linked list contains ---------&-------------

a) data & pointer to hold the address of that node.

b) data & pointer to hold the address of next node.

c) data & pointer to hold the address of previous node.

d) pointer to hold the address of next and previous node.


Ans b

2) what does the last node link contain

a) address of first node

b) address of that node

c) null

d) address of previous node

ans c

3) steps involved in insertion of a node

a) Creating a new node.

b) Accepting data into the node

c) If the list does not exist, assign start to the new node.

d) If the list exists insert the new node at the end of the list.

a) 1234

b) 1324

c) 4321

d) 3124

Ans a)

4) steps involved in traversing the list

1) store the address of the start node in a temporary variable.

2) Repeat steps 2 & 3 until the the temporary pointer points to null.

3) Print data in the node.

4) Move the temporary pointer pointer to the next node.


a) 1234

b) 1432

c) 1342

d) 2314

Ans c

5) steps involved in traversing the list

1) Free the memory occupied by the deleted node.

2) if the node to be deleted is the start then start is made to point to the next node.

3) searching for the node to be deleted by comparing the data with the data entered by the user.

4) if the node to be deleted is in the middle of the list the previous node is made to point to the next
node.

e) 1234

f) 3241

g) 1324

h) 2431

Ans f

6) if a node (q) is to be inserted at the beginning the operations which are performed is

1) q->next =start->next

start =q;

2) start=q;

q->next=start;
3) q->next=start;

q=start;

4) q->next =start;

start =q;

ans 4

7) when start and last points to same node,how many elements are present

1) 0 2)1 3)2 4)3

Ans 2

8)memory is allocated in single linked list

a) dynamically b)compile time c)statically d) linking time.

Ans : a

1).What would be the output of the following program.

main()

int a[5]={2,3};

printf("\n %d %d %d",a[2],a[3],a[4]);

(a) garbage value (b) 2 3 3 (c) 3 2 2 (d) 0 0 0


ans::d

2).What would be the output of the following program.

main()

int i=-3,j=2,k=0,m;

m=++i&&++j||++k;

printf("\n %d %d %d %d",i,j,k,m);

(a) -2 3 0 1 (b) -3 2 0 1 (c) -2 3 1 1 (d) error

ans::a

3) main()

Int n[25];

n[0]=100;

n[24]=200;

printf(%d%d,*n,*(n+24)+*(n+0));

a)100 200 b) 100 300 c) 0,100 d) 0,200

4)

main()

char str[]="I am in wipro";

printf("%s\n",&str[5]);
}

ans::in wipro

5) main()

Char *p=algc;

Printf(%c,++*p++);

Printf(%c,*++p);

a)al b) mg c) lg d) none

ans::none.....bg

6)main()

void fun(int);

int n=3;

fun(n);

void fun(int n)

if(n>0)

fun(--n);
printf("%d",n);

fun(--n);

ans::0120

7).What would be the output of the following program.

main()

struct emp

char name[20];

int age;

float sal;

};

struct emp e = {"tiger"};

printf("\n %d %f",e.age,e.sal);

(a) 0 0.000000 (b) Garbage values (c) Error (d) none of the above

ans::a

8).main( )

int a[ ] = {10,20,30,40,50},j,*p;

for(j=0; j<5; j++)


{

printf(%d ,*a);

a++;

p = a;

for(j=0; j<5; j++)

printf(%d ,*p);

p++;

Ans::Error Lvalue Required...can't change the base address a++

9.main()

int c[ ]={2,3,4,6,5};

int j,*p=c,*q=c;

for(j=0;j<5;j++)

printf(" %d ",*p);

++q;

for(j=0;j<5;j++)

{
printf(" %d ",*p);

++p;

ans::222223465

10.

#define ABC 20

#define XYZ 10

#define XXX ABC - XYZ

void main()

int a;

a = XXX * 10;

printf("%d\n", a);

ans::-80

11. #define calc(a, b) (a * b) / (a - b)

void main()

int a = 20, b = 10;


printf("%d\n", calc(a + 4, b -2));

12.void main()

int cnt = 5, a;

do {

a /= cnt;

} while (cnt --);

printf ("%d\n", a);

ans::Error..divide error

13. void main()

int a, b, c, abc = 0;

a = b = c = 40;

if (c) {

int abc;

abc = a*b+c;

}
printf ("c = %d, abc = %d\n", c, abc);

ans::40 0

14.main()

int k = 5;

if (++k < 5 && k++/5 || ++k <= 8)

printf("%d\n", k);

ans::7

15.main()

static char names[5][20]={"pascal","ada","cobol","fortran","perl"};

int i;

char *t;

t=names[3];

names[3]=names[4];

names[4]=t;

for (i=0;i<=4;i++)

printf("%s",names[i]);

ans::Error......base address can't be changed names[3]=names[4]


16.main()

int x=20;y=35;

x=x++ + y++;

y=++y + ++x;

printf("x=%d y=%d\n",x,y);

ans::57 94

17.Assume that integer is 4 bytes,pointer as 4 byter and character

as 1 byte,then predict the output

struct student

int a;

char name[10];

int *p;

}s1,*s2;

printf("%d%d",sizeof(s1),sizeof(*s2));

a) 18,18

b)18,4

c) 4,18

d) 4,4
18.int fun(int x)

int y=55;

return((x-y)?y:x);

main()

int a=20;

fun(a);

printf("%d",y);

ans::20

19.int compute(int n)

if(n>0)

n=compute(n-3)+compute(n-1);

return(n);

return(1);

void main()

printf("%d",compute(5));
}

20.int main()

char *ptr="abcdefgh";

char *sptr;

sptr=ptr+5;

printf("%s",sptr);

ans::fgh

1. printf("%d %d %d",sizeof(25.75),sizeof(123),sizeof(p))

a. 2 2 2 b. 4 2 2 c. 8 4 1 d. 8 2 2

ans::d

2. int i=5;
fun( )

printf("%d\n", i * 3);

main( )

int i= 2;

int i = 3;

printf(" %d", i);

fun();

a. 3, 15

b. 3, 6

c. 3

d. 0

Ans::a

3. #define xsq(x) x*x

main( )

int i, j;

i = 5;

j = xsq(i-2);

printf(%d\n, j);
}

a. 7

b. 9

c. 13

d. 29

Ans::-7

4. main( )

int a=35;

printf( %d %d %d\n, a == 35,a=50,a>40);

a. 1 50 1

b. 1 50 0

c. 0 50 0

d. 0 50 1

ans::c

Posted by Wipro Emp

Reactions:

Email This

BlogThis!

Share to Twitter

Share to Facebook

Share to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home

Subscribe to: Post Comments (Atom)

Blog Archive

2011 (1)

2012 (35)

Apr (4)

May (22)

C Programs for wipro Interview

Wipro Engineering and Non-Engineering Graduates El...

WASE Program 2012 | Registration | Course | Exam |...

WASE M.S Exams 2012 | WASIAN Exam Experience

WASE MS Syllabus | MS Program | MS Course | MS Deg...

WASE Salary Package 2012 | Review | Salary hike | ...

Wipro Call Letter Fresher 2012 | Format

FRP | TRP | CRP | PRP - Wipro Training

Part 1: FRP Dumps | C Puzzle | C++ Puzzle | DataSt...

Part 2: FRP Dumps | C Puzzle | C++ Puzzle | DataSt...

Part 3: FRP Dumps | C Puzzle | C++ Puzzle | DataSt...

Part 4: FRP Dumps | C Puzzle | C++ Puzzle | DataSt...


Part 5: FRP Dumps | C Puzzle | C++ Puzzle | DataSt...

Part 6: FRP Dumps | C Puzzle | C++ Puzzle | DataSt...

Part 7: FRP Dumps | C Puzzle | C++ Puzzle | DataSt...

Eligibility Criteria For WASE Student | BSC Gradua...

Eligibility Criteria For WISTA students | B.Sc/M.S...

Checklist - Documents Required on the Day of Repor...

WIPRO Bond Period | Agreement for Engineering | No...

Clarifications on your date of joining | Wipro Tol...

Wipro Joining Criteria | Arrears and backlogs need...

WIPRO Medical Check Up Letter Format |

Aug (3)

Sep (2)

Oct (1)

Nov (1)

Dec (2)

2013 (3)

2015 (1)

Click below

Discover your Life Purpose

Popular Posts

Wipro Interview Questions and Answers for Freshers


Wipro Document Verification | Wipro Checklist | Documents need to be submitted | Joining formalities

Wipro Salary Category based on Training Results | Salary Structure for fresher India

Part 1: FRP Dumps | C Puzzle | C++ Puzzle | DataStructure Puzzle

FRP | TRP | CRP | PRP - Wipro Training

List of Streams | Technologies | Domains in Wipro

Clarifications on your date of joining | Wipro Toll free number India

Wipro Campus CDC5 Pics | Photos | Pictures | Images | Chennai

Wipro Call Letter Fresher 2012 | Format

WASE Salary Package 2012 | Review | Salary hike | Stipend | Revised Scholarship

Total Pageviews

564,257

Wipro Candidate Experience since 2011. Awesome Inc. theme. Powered by Blogger.

Você também pode gostar