Академический Документы
Профессиональный Документы
Культура Документы
Table of Contents
SET 1: 2018001ALL ....................................................................................... 1
SET 1: 2018012ALL
1) Where the local variables are stored?
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