Anda di halaman 1dari 21

Six Phrase – The Finishing School

93A GKD Nagar P.N.Palayam Coimbatore – 641037


Prabhu N.D. – 99946 75750
www.sixphrase.com | sixphrase@gmail.com

Table of Contents
SET 1: 2018001ALL ....................................................................................... 1

SET 1: 2018012ALL
1) Where the local variables are stored?

Aptitude Training | Technical Training | English Language Training


Soft Skills Training | Finance Training | Placement Services
a) Disk
b) stack
c) heap
d) 13

2) which of the following indicate the end of the file ?


a)Feof()
b)EOF
c)both feof() and EOF
d)none of the mentioned options

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

5) Select the missing statement ?


#include<stdio.h>
long int fact(int n)
int main()
{
\\missing statement
}
long int fact(int n)
{
if(n>=1)
return n*fact(n-1);
else
return 1;
}
a)printf(“%ll\n”,fact(5));
b)printf(“%u\n”,fact(5));
c)printf(“%d\n”,fact(5));
d)printf(“%ld\n”,fact(5));

6) How many times the below loop will be executed?


#include<studio.h>
int main ( ) {
int x,y ;
for (x=5;x>=1;x--)
{
for(y=1;y<=x;y++)
printf(“%d\n”,y);
}
}
a)15
b)10
c)11
d)13

7) Which datatype has more precision?


(a) double
(b) float
(c) insigned longint
(d) long int

8) Which of the following is user-defined data type?


a) Long int
b) double
c) enum
d) unsigned long int

9) What will be the output/error?(for input 6,9)


#include<stdio.h>
int fg(int,int)
int main()
{
int n1,n2,g;
scanf(%d%d”,&n1,&n2);
g=fg(n1,n2);
printf(“%d”,g);
}
int fg(int x,int y)
{
while(x!=y)
{
if(x>y)
return fg(x-y,y);
else
return fg(x,y-x);
}
return x;
}
a) 3
b) 6
c) 9
d) error

10) What is the dangling pointer?


A. points to garbage value
B. points to function
C. both a and b
D. none of the above

11) A dangling pointer is


A. pointer whose value is fixed
B. pointer that does not point to a valid memory location
C. pointer that has been wrongly assigned multiple memory locations
D. pointer that cannot be made to point to alternative memory location
12) int main(int argc, char **argv)
Comment about : char ** argv
a)Pointer to pointer
b) it is the file name and argument passed
c) it is an array of character pointers
d) Compile time error

13) main(int argc, char**argv)


In the above definition of main function the variable argv denotes…
a) An array of character pointers each pointing to the command line parameters
b) An array of character pointers the first array item pointing to the program
name and the remaining pointing to the command line parameters
c) A pointer to character that points to command line parameter
d) A pointer to a pointer to the points to the memory location where the program
has been loaded into the memory

14) How to release the dynamic memory?


a)Free( )
b) truncate( )
c) delete( )
d) release( )

15) What library function is used to release the allocated memory in C?


a) Dalloc()
b) Release()
c) Free()
d) Freemem()

16) What is the purpose of ftell?


A. to get the current file name
B. to get the current file status
C. to get the current file attribution
D. to get the current file position

17) What is recursion?


A. looping
B. a function calls another function repeatedly
C. function calls repeatedly
D. function call itself repeatedly

18) What is the similarity between enum and structure?


A. can assign new values
B. can create new data types
C. nothing is common
D. they are same

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

20) What will be the output of the below code


# include <stdio.h>
int main()
{
float f=0.1;
if (f ==0.1)
printf(“NO\n”);
return 0;
}
a) NO
b) ERROR
c) NO OUTPUT
d) Successfully compiled but no Output

21) A memory leak happens when?


A. a program allocates memory in heap but forget to delete it
B. a program allocate memory in stack
C. when an un signed pointer is freed using free function
D. when reallocate () is called on a pointer that is not allocated

22) Which of the below is NOT a fundamental data type


a. Unsigned long int
b. Enum
c. Long int
d. double

23) The similarity between a structure, union and enumeration is?


a. All of them let us design new pointers.
b. All of them let us design new values.
c. All of them let us design new data types.
d. Size of all of them do not vary from program to program.

24) In the below code, what concept is used


# include <stdio.h>
long int fact (int n);
int main ( )
{
int n;
printf ( “ Enter a positive integer:”);
scanf (“ %d ”, &n);
printf (“ Factorial of %d = %1d”, n , fact(n));
return 0;
}
long int fact ( int n )
{
if ( n >= 1)
return n * fact ( n – 1);
else
return 1;
}
a. Iteration
b. Segmentation
c. Encapsulation
d. Recursion

a)Function calls from one to other function


b) Repeatedly calls itself(recursive)
c) Conditional looping

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].* % / - + =

26) How many times Hello will print?


#include <stdio.h>
int main (void)
{
int I;
for (i=0;i-5;i--);
{
printf(“Hello”);
}
}
A. compilation error
B. 1
C. 4
D. runtime error

27) How many times loop will be executed?


#include<stdio.h>
int main( )
{
int i;
for(i=0;i<5;i++)
{
printf("Hello\n");
}
}
A)5
B)1
C)0
D)3

28) How many times Hello will print?


#include<stdio.h>
int main( )
{
int i;
for(i=0;i<5;i++);
{
printf("Hello");
}
}
A. compilation error
B. 1
C. 4
D. runtime error

29) Which of the following statement is true about the c language?


A.(void *)0 is different from a null pointer (wikepedia says this is wrong)
B.null pointer is another name for un initialized pointer
C.calloc() can be used only for character pointer allocation
D.char* i=0 and char *i= null means the same

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

33) atoi() function is used to


A. gets index value of character in an array
B. converts ASCII character to its integer value
C. converts an array of characters to array of equivalent integer
D. convert a character string to its equivalent integer value

34) Which has the highest precision?


a)Float
b) Double
c) unsigned long int
d) long int

35) Which of the following functions is NOT declared in string.h?


a)Strcpr ( )
b)strcpy ( )
c) strlen ( )
d) strptr()

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[]

37) Which of the following statement is true about C language?


a.There is a maximum limit to number of case instance inside a switch statements
b.Two case constant within the same statements can have the same value
c. Do while loop is used to ensure that the statements within the loop are executed
at least twice
d.Continue keyword skips one iteration of loop

38) What does the default header file contain?


a)Prototypes
b) Declaration
c) implementations
d) all the above

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.

40) Which of the below statements is true (need to check)


a. None of the other three choices
b. A static function can return only a static variable
c. A static variable can be declared only inside a static function
d. Variables passed to a static function should also be static

41) The output of the below program :


# include <stdio.h>
int main ()
{
int n, ch;
for (n=7; n!=0; n --)
printf (“n = %d”, n --);
ch = getchar();
return 0;
}
a) Numbers 7 to 1 in descending order
b) Numbers 7 to 0 in descending order
c) None of the other 3 choices as there is a compilation error
d) Infinite loop. Program never ends

42) Given the below statements about C programming language;


1) main() function should always be the first function present in a C program file
2) all the elements of an union share their memory location
3) A void pointer can hold address of any type and can be typcasted to any type
4) A static variable hold random junk value if it is not initialised
Which of the above are correct statements?
A) 2,3
B) 1,2
C) 1,2,3
D) 1,2,3,4

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;

46) Which of the following statement is true about c language?


a. C language is not strict about indentation and alignment of if ,for,while and
do statement TRUE
b. The loop counter in a for loop should be of int data type only - FALSE
c. "= =" operator is used to assign an exact value with correct accuracy. FALSE
d. Under special conditions keywords can be used as variable name. FALSE

47) Which of the below statements is true?


a. C language allows negative index values in an array. - TRUE
b. Function rewind() makes execution of the program restart from the beginning -
FALSE
c. We cannot use any name in place of argv and argc as command line arguments -
FALSE
d. Constant pointer and pointer to a constant are the same. - FALSE

48) Which of the following statement is true about C language?


a. Realloc can be used to change size of an array
b. If a function explicitly dose not return a value, then default value 0 will
return
c. Unary operator takes only one operand
d. It is not possible to write a working program in C without using semicolon

49) Which of the following below about static variable is true?


a. A variable that is static is assigned on address at build [compile, link]time
b. A static variable inside a function keep the values between invocation
c. All of the three statement are true
d. A static variable will auto initialize to zero at the start of the
program/function

50) Which of the statement about array and pointer is correct?


a. An array memory size can be modify using pointer
b. Array has fixed memory size whereas pointer can point on array size as
we required at run time
c. Both array and pointer can be resize using realloc()
d. None of other three options are correct
51) Recursion is when
a. A dummy function is executed to create time delays
b. A function calls another function without passing any parameters
c. A block of code is executed multiple times based on a condition
d. A function calls itself
52) To print a double value which format specifier should be used?
a. %lf
b. %Lf
c. %f
d. %df
53) #include<stdio.h>
main(int argc, char **argv)
{
puts(argv[argc] );
}
The above C program is compiled and executable is named as test.
It is then invoked in command line as below :
Test 1 2 3 4 5
What will be the value of argv that will be printed?
a. 5
b. Run time error
c. No output
d. 1
54) What will be output of the program ?
#include<stdio.h>
main()
{
static int a=2,b= 4,c= 8;
static int *arr1[2] ={&a, &b};
static int *arr1[2] ={&b, &c};
int* (*arr[2] *arr1[2] )[2] = {&arr1, &arr2};
printf(“%d”, *(*(**(arr +1)+1) ) ) ;
}
55) To write a struct into a file in C language, we can use
a. fwrite()
b. Not possible to write composite data types
c.
d. fputc()
56) A program tried to compile and link the below code. What he would have
encountered ?
main()
{
int i=10;
printf(“%d”,i);
}
a. Run time error as stdio.h is not present
b. Compile time error as stdio.h is not included
c. Compile error as there is no returns statement in the main function
d. Program would have printed 10
57) What will be the output of the below program?
#include <stdio.h>
Main ()
{
static int a=2, b=4, c=8;
static int *arr1[2]=(&a, &b);
static int *arr2[2]=(&b, &c);
int* (*arr[2]) [2]=(&arr 1, &arr2);
printf(“%d”, *(*(**(arr+1)+1))):
}
58) #include <stdio.h>
Main (int argc, char ** argv)
{
puts (argv[argc]);
}
The above program is complied and executable is named as test. It is then invoked
in command line as below:
Test 1 2 3 4 5
What will be the value of argv that will be printed?
a) 5
b) Run time error
c) No output
d) 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

62) Which of the following is correct


i) (a=b)? (c==d):(e==f)
ii) (a==b)?(c=d):(e=f)
iii) (a=b)?(c=d):(e=f)
iv) (a==b)?(c==d):(e==f)
a) i is correct
b) i and ii is correct
c) ii and iv is correct
d) all the above.

63) which is true?


i) global variable can't start auto variable
ii)local variable are static
iii)extern are auto variable
iv) all the above

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

Anda mungkin juga menyukai