159. Find the output

# define mult(x) x*y

main()

{

mult(2+1);

}

Answer :

160. Find the output

#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;
}

Answer :

POINTERS

161. Find the output

main()

{

char a[10];

char *p1=a;

char *p1=&a[a];

{

*p1++;

*p2--;

}

}

Answer :

162. Find the output

main()

{

int *j;

{

int i=10;

j=&i;

}

printf("%d",*j);

}

Answer:

10

Explanation:

The variable i is a block level variable and the visibility is inside that block only. But the lifetime of i is lifetime of the function so it lives upto the exit of main function. Since the i is still allocated space, *j prints the value stored in i since j points i.

163. Find the output of the following.
main()
{
int i;
char *p;
i=0X89;
p=(char *)i;
p++;
printf("%x\n",p);
}

Answer: 0X8A

164. What is the output of the following program?
main()
{
char *src = "Hello World";
char dst[100];
strcpy(src,dst);
printf("%s",dst);
}strcpy(char *dst,char *src)
{while(*src) *dst++ = *src++;
}
)

a)"Hello World"

b)"Hello"

c)"World"

d) NULL

e) unidentified

Answer : d

165. Find the output for the following C program
main()

{

int x=5,y;
y= x&y;

return y;

}

Answer :

166. What is the output of the following program
main()
{

int var=25,varp;
varp=&var;
varp p = 10;
fnc(varp)
printf("%d%d,var,varp);
}
(a) 20,55
(b) 35,35
(c) 25,25
(d)55,55

Answer : d

167.Find the output

main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}

Answer:

168.Find the output

main()

{

int *p, i==4;

p==&i;

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

}

Answer:

OBJECTIVE TYPE QUESTIONS

169.Printf can be implemented by using ______list.

Answer: Variable length argument

170. which of the following is not a ANSI C language keyword?

Answer : Function.

171. When an array is passed as parameter to a function, which of the following statement is correct choice:

a)The function can change values in the original array

b) In C parameters are passed by value. The funciton cannot change the original value in the array

c) It results in compilation error when the function tries toaccess the elements in the array

d) Results in a run time error when the funtion tries to access the elements in the array

Answer: a)

172 . The type of the controlling expression of a switch statement cannot be of the type

a) int b) char c) short d)float e) none

Answer : d)

173. What is the value of the expression (3^6) + (a^a)?

a) 3 b) 5 c) 6 d) a+18 e) None

Answer : b)

174. What is the value assigned to the variable X if b is 7 ?

X = b>8 ? b <3 : b>4 ? b>1:b;

a) 7 b) 28 c) 3 d) 14 e) None

Answer : c)

175. In signed magnitude notation what is the minimum value that can be represented with 8 bits?
a) -128 b) -255 c) -127 d) 0

Answer :

176. WHICH IS NOT BASIC data type?

Answer : char*

177. Argument in funtion can be passed
1)by value 2)by reference 3)??

Answer :

178.Hint: In switch statement float is not used

179. What is the sizeof(long int)
(a) 4 bytes
(b) 2 bytes
(c) compiler dependent
(d) 8 bytes

Answer :

180.The declaration of the variable does not result in one of the following

Answer : allocation of the storage space for the variable.

182. In C parameters are passed by

Answer : value only.

183. Two variables cannot have the same name if they are

Answer : in the same block.

184. Which of the following is the proper declaration of a pointer?
A. int x;
B. int &x;
C. ptr x;
D. int *x;

Answer : d

185. Which of the following gives the memory address of integer variable a?
A. *a;
B. a;
C. &a;
D. address(a);

Answer : c

186. Which of the following gives the memory address of a pointer a?
A. a;
B. *a;
C. &a;
D. address(a);

Answer : a

187. Which of the following gives the value stored in pointer a?
A. a;
B. val(a);
C. *a;
D. &a;

Answer : c

188. Which of the following is the proper keyword to allocate memory in C?
A. new
B. malloc
C. create
D. value

Answer : b

189. Which of the following is the proper keyword to deallocate memory?
A. free
B. delete
C. clear
D. remove

Answer : a

190. What is the correct value to return to the operating system upon the successful completion of a program?
A. -1
B. 1
C. 0
D. Programs do not return a value.

Answer : c

191. What is the only function all C programs must contain?
A. start()
B. system()
C. main()
D. program()

Answer : c

192. What punctuation is used to signal the beginning and end of code blocks?
A. { }
B. -> and <-
C. BEGIN and END
D. ( and )

Answer : a

193.What punctuation ends most lines of C code?
A. .
B. ;
C. :
D. '

Answer : b

194. Which of the following is a correct comment?
A. */ Comments */
B. ** Comment **
C. /* Comment */
D. { Comment }

Answer : c

195. Which of the following is not a correct variable type?
A. float
B. real
C. int
D. double

Answer : b

196. Which of the following is the correct operator to compare two variables?
A. :=
B. =
C. equal
D. ==

Answer : d

197. Which of the following is true?
A. 1
B. 66
C. .1
D. -1
E. All of the above

Answer : e
198. Which of the following is the boolean operator for logical-and?
A. &
B. &
C. |
D. |&

Answer : b
199. Evaluate !(1 & !(0 || 1)).
A. True
B. False
C. Unevaluatable

Answer : a
200. Which of the following shows the correct syntax for an if statement?
A. if expression
B. if{ expression
C. if( expression)
D. expression if

Answer : c

201. What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?
A. 10
B. 9
C. 0
D. 1

Answer : a

202. When does the code block following while(x<100) execute?
A. When x is less than one hundred
B. When x is greater than one hundred
C. When x is equal to one hundred
D. While it wishes

Answer : a

203. Which is not a loop structure?
A. For
B. Do while
C. While
D. Repeat Until

Answer : d

204. How many times is a do while loop guaranteed to loop?
A. 0
B. Infinitely
C. 1
D. Variable

Answer : c

205. Which is not a proper prototype?
A. int funct(char x, char y);
B. double funct(char x)
C. void funct();
D. char x();

Answer : b

206. What is the return type of the function with prototype: "int func(char x, float v, double t);"
A. char
B. int
C. float
D. double

Answer : b

207. Which of the following is a valid function call (assuming the function exists)?
A. funct;
B. funct x, y;
C. funct();
D. int funct();

Answer : c

208. Which of the following is a complete function?
A. int funct();
B. int funct(int x) {return x=x+1;}
C. void funct(int) { printf( "Hello");
D. void funct(x) { printf( "Hello"); }

Answer : b

209. Which follows the case statement?
A. :
B. ;
C. -
D. A newline

Answer : a

210. What is required to avoid falling through from one case to the next?
A. end;
B. break;
C. Stop;
D. A semicolon.

Answer : b

211. What keyword covers unhandled possibilities?
A. all
B. contingency
C. default
D. other

Answer :c

212. What is the result of the following code?

x=0;
switch(x)
{
case 1: printf( "One" );
case 0: printf( "Zero" );
case 2: printf( "Hello World" );
}

A. One
B. Zero
C. Hello World
D. ZeroHello World

Answer : d

213. Which of the following accesses a variable in structure b?
A. b->var;
B. b.var;
C. b-var;
D. b>var;

Answer : b

214. Which of the following accesses a variable in structure *b?
A. b->var;
B. b.var;
C. b-var;
D. b>var;

Answer : a

215. Which of the following is a properly defined struct?

a.struct {int a;}
B. struct a_struct {int a;}
C. struct a_struct int a;
D. struct a_struct {int a;};

Answer : d

216. Which properly declares a variable of struct foo?
A. struct foo;
B. struct foo var;
C. foo;
D. int foo;

Answer : b

217. Which of the following correctly declares an array?
A. int anarray[10];
B. int anarray;
C. anarray{10};
D. array anarray[10];

Answer : a

218. What is the index number of the last element of an array with 29 elements?
A. 29
B. 28
C. 0
D. Programmer-defined

Answer : b

219. Which of the following is a two-dimensional array?
A. array anarray[20][20];
B. int anarray[20][20];
C. int array[20, 20];
D. char array[20];

Answer : b

220. Which of the following correctly accesses the seventh element stored in foo, an array with 100 elements?
A. foo[6];
B. foo[7];
C. foo(7);
D. foo;

Answer : a