6phrase - 2019 - Tcs - C MCQ
6phrase - 2019 - Tcs - C MCQ
6phrase - 2019 - Tcs - C MCQ
Table of Contents
SET 1: 2018012ALL.........................................................................................2
SET 2: 2018002PRIYA...................................................................................21
3) When reading from a file, to test whether we have reached its end, which
function can be used?
a) eof()
b) endOfFile()
c) feof()
d) fend()
4) If a function’s return type is not explicitly defined then it’s default to __( in C)
a) Int
b) float
c) void
d) error
STAR QUESTION
19) What will be the output of the below code
# include <stdio.h>
int main()
{
float f = 0.1;
if (f ==0.1)
printf(“YES\n”);
else
printf(“NO\n”);
return 0;
}
ANS:NO
25) Which of the following is the correct order of evaluation for the below
expression?
z=x+y*z/4%2-1
[A].* / % + - =
[B].= * / % + -
[C]./ * % - + =
[D].* % / - + =
STAR QUESTION
30) In the below program expects the user to enter a word. If the user enter the
word as MADAM what is the output value printed:
#include <stdio.h >
#define MAX 20
Char*fn(char []);
Int main(){
Char str[MAX],*rev;
Printf(“Enter a word of size not more than 15 characters:”);
Scanf(“%s”,str);
r-fn(str);
printf(“%s\n”,r);
return 0;
}
Char* fn (char str[]){
Static int i=0;
Static char r [MAX];
If (*str){
Fn (str+1);
r[i++]=*str;
}
Return r;
}
ANS: COMPILATION ERROR. Variable “r” is not declared.
31) In the below program expects the user to enter a word. If the user enter the
word as HELLO what is the output value printed:
#include <stdio.h >
#define MAX 20
Char*fn(char []);
Int main(){
Char str[MAX],*rev;
Printf(“Enter a word of size not more than 15 characters:”);
Scanf(“\a”,str);
r-fn(str);
printf(“\s\n”,r);
return 0;
}
Char* fn (char str[]){
Static int i=0;
Static char r [MAX];
If (*str){
Fn (str+1);
r[i++]=*str;
}
Return r;
}
ANS: COMPILATION ERROR. Variable “r” is not declared.
STAR QUESTION
32) What is the if size for char is 1, int is 4,double is 8?
#include<stdio.h>
union u
{
int i;
char c;
double d;
};
int main()
{
union ui, u1;
printf(“%d”,sizeof(u1));
return 0;
}
Ans.Error
36) While declaring parameters for main, the second parameter argv should be
declared as
A.char arg
B.char argv[]
C. char argv[]
D.char**argv[]
STAR QUESTION
39) In the below code the program expects the user to enter a word. If the user
enters the word as ABRACADABRA what is the output value printed?
#include<stdio.h>
#define MAX 20
char *fn(char( ) );
int main( )
{
char str[MAX], * rev;
Printf(“ Enter word size not more than 15 characters: ”);
Scanf(“%s”,str);
r= fn(str);
printf(“%s\n”,r);
return 0;
}
char* fn(char str( ) )
{
static int 1=0;
static char r[MAX];
if(*str)
{
fn(str+1);
r[i++]=*str;
}
return r;
}
ANS: COMPILATION ERROR. Variable “r” is not declared.
43) #include<stdio.h>
#include<stdlib.h>
Int main(argc, argv)
int argc;
char **argv;
{
FILE fp; - Error (it should be File *fp
fp=fopen(“foo”, “r”); - Error
if(!fp)
{
printf(“unable to open file”);
exit(1);
}
fclose(fp);
return 0;
}
In the above code, there is an error at line number_______
a) No error
b) Line 5
c) Line 8
d) Line 7
44) #include<stdio.h>
void fn(int **p);
int main()
{
int a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12};
int *ptr;
ptr=&a[0][0];
fun(&ptr);
return 0;
}
void fun(int **p)
{
printf(“%d\n”,**p);
}
The output of the above code will be ______
a) 2
b) The code has a error and hence will not run
c) 1
d) 0
STAR QUESTION
45) In the below code, the program expects the user to enter one number. if the
user enters the number as 13 what is the output value printed:
#include <stdio.h>
int fn(int,int);
int main()
{
int num, p;
printf(‘enter a positive integer : “);
scanf (“%d”, &num);
p = fn(num,num/2);
printf (“%d\n”,p);
return 0;
}
int fn (int num,int i)
{
if(i==1)
{
return 1;
}
else
{
if (num% i==0)
return 0;
else
fn( num,i-1);
}}
// Answer : 1
Note : fn is a function to check whether input is prime or not.
fn (13, 6);
fn (13, 5);
fn (13, 4);
fn (13, 3);
fn (13, 2);
fn (13, 1); returns 1;
59) #include
int main(){
float a=5.89
printf(%.0f,a);
}
a) 6
b) 2.89
c)2.890000
d)it has no conio.h so its error
60)
int a=5;
char c='c';
printf("%d",a+c);
a) compiles and runs
b) compilation error
c) integer and character cannot be added
d) conio.h is not given so error
61) Eesha writes function and save as file.c but she forget to call the function
a) programs compiles and runs
b) it compiles but causes runtime error
c)run time error
64) #include<stdio.h>
int main()
{
static int i;
int j;
for(j=0;j<10;j++)
{
i+=2;
i-=j;
}
printf("%d",i) ;
}
a) - 27 b) - 25 c) cannot be determined d) – 21
SET 2: 2018002PRIYA
1.Neelam wants to share her code with a colleague, who may modify it. Thus she
wants to include the date of the program creation, the author and other she wants
to include the date of the program creation, the author and other information with
the program. What component should she use?
A.Header files
B.Iteration
C.Comments
D.Preprocessor directive
Answer: D
2.What is the output of the following code statements? The compiler saves the first
integer at the memory location 4165 and the rest at consecutive memory spaces in
order of declaration. Integer is one byte long.
A.30
B.4165
C.40
D.4166
Answer: C
3.A data type is stored as an 6 bit signed integer. Which of the following cannot be
represented by this data type?
A. -12
B. 0
C.32
D.18
E.64
Answer: c
4.A language has 28 different letters in total. Each word in the language
iscomposed of maximum 7 letters. You want to create a data-type to store a word
ofthis language. You decide to store the word as an array of letters. How many bits
will you assign to the data-type to be able to store all kinds of words of the
language.
a.7
b.35
c.28
d.196
Answer: b
5. A 10-bit unsigned integer has the following range:
a.0 to 1000
b.0 to 1024
c.1 to 1025
d.0 to 1023
Answer: D
6.Parul takes as input two numbers: a and b. a and b can take integer values
between 0 and 255. She stores a, b and c as 1-byte data type. She writes the
following code statement to process a and b and put the result in c. c = a + 2*b To
her surprise her program gives the right output with some input values of a and b,
while gives an erroneous answer for others. For which of the following inputs will it
give a wrong answer?
a. a = 10 b = 200
b. a = 200 b = 10
c. a = 50 b = 100D
d. a = 100 b = 50
Answer: a
7.Which is used to convert source code to target language
a. linker
b. compiler
c. executer
d. loader
Answer: b
8. Tricha wants to store a list of binary data.Which of following data types should
she use?
a. Integer
b. Float
c. Character
d. Boolean
Answer: d
9.Which of the following options is an exception to being a part of composite data
types?
a. Union
b. Array
c. Structure
d. Stack
Answer: d
10. The datatype is store as 6 but unsigned integer. Which of the following can’t be
represented by the this datatype:
a. -12
b. 0
c. 32
d. 18
Answer: a