(Tcs MCQS) : C Programming Language by K.V.Ramana Naresh Technologies

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 28

[TCS MCQs]

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 1


Question: 1

Which of the below has the highest precision?

A. float

B. long int

C. double

D. unsigned long int

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 2


Question: 2
A programmer forgot to include a header file in the below program.
What file is that.
int main()
{
printf(“%f\n”, sqrt(120.0));
return 0;
}
A. math's
B. conio.h
C. funcs.h
D. stdlib.h

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 3


Question: 3
In the below code, the program expects the user to enter a word. If the
user enters 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", r);
return 0;
}
C Programming Language by K.V.Ramana M.Tech Naresh Technologies 4
char* fn(char str[])
{
static int i=0;
static char r[MAX];
if(*str)
{
fn(str+1);
r[i++]=*str;
}
return r;
}

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 5


Question: 4

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 is %ld", n, fact(n));
return 0;
}
C Programming Language by K.V.Ramana M.Tech Naresh Technologies 6
long int fact(int n)
{
if(n>=1)
return n*fact(n-1);
else
return 1;
}
A.Recursion
B.Encapsulation
C.Segmentation
D.Iteration

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 7


Question: 5

Recursion is when:
A. A function calls itself
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 dummy function is expected to create time delays

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 8


Question: 6

What library function is used to release the allocated memory in


C?
A. free()
B. release()
C. freemem()
D. dealloc()

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 9


Question: 7

The similarity between structure, union and enumeration is:


A. Size of all of them do not vary from program to
program
B. All of them let us define new data types
C. All of them let us define new values
D. All of them let us define new pointers

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 10


Question: 8
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;
}

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 11


Question: 9

Where are local variables stored?


A. In hard disk
B. In a Queue
C. In Heap Memory
D. In Stack Memory

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 12


Question: 10

Which is the below is not a fundamental data type?


A. unsigned long int
B. double
C. enum
D. long int

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 13


Question: 11

Following is the function is used to get status of the file.


Following is the function is used to get position of the file pointer.
A. ftell()
B. fopen()
C. fstatus()
D. fclose()

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 14


Question: 12

Which of the function is used to locate the end of file?


A. feof()
B. eof()
C. enfoffile()
D. end()

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 15


Question: 13

Which of the following function is not in string.h header file.


a. strcpy()
b. strptr()
c. strlen()
d. strrev()

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 16


Question: 14

What is the initial of static variable?


A. Garbage
B. 0
C. -1
D. None of the above

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 17


Question: 15

What is the use of atoi()


A. Converts string to integer
B. Converts integer to string
C. Converts string to float
D. None of the above

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 18


Question: 16

What is the use of argv[]


Array of character Pointer
Stored arguments passed from cmd prompt

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 19


Question: 17.

What is the use of argc.


Total number arguments passed from cm to main

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 20


Question: 18

Following is not a mathematical Math functions:


A. Sqrt()
B. Pow()
C. Round()
D. Ceil()

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 21


Question: 19
What is the output of the following code?
#include <stdio.h>
void main()
{
increment();
increment();
}
void increment()
{
static int i;
i=i+1;
printf("%d\n", i);
} OUTPUT:-12

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 22


Question: 20
What will be the output of the following code segment?
#include<stdio.h>
void fn()
{
static int i=5;
printf("%d\t",++i);
}
int main()
{
fn();
fn();
return 0;
}
A. 5 5
B. 6 6
C. 6 7
D. 7 7
C Programming Language by K.V.Ramana M.Tech Naresh Technologies 23
Question: 21

What is the output of this C code?


#include <stdio.h>
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **p);
}
A. 5 5 5
B. 5 5 junk
C. 5 junk junk
D. Compile time error
C Programming Language by K.V.Ramana M.Tech Naresh Technologies 24
Question: 22

Which of the following statements about stdout and stderr are true?
A. They both are the same
B. Run time errors are automatically displayed in stderr
C. Both are connected to the screen by default.
D. stdout is line buffered but stderr is unbuffered.

Standard output and error

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 25


Question: 23
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

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 26


Question: 24

If a function is defined as static, it means


A. The value returned by the function does not change
B. All the variable declared inside the function automatically will
be assigned initial value of zero
C. It should be called only within the same source code /
program file.
D. None of the other choices as it is wrong to add static prefix to
a function

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 27


Question: 25

Comment on the below while statement


while (0 == 0) { }
A. It has syntax error as there are no statements within braces {}
B. It will run forever
C. It compares 0 with 0 and since they are equal it will exit the loop
immediately
D. It has syntax error as the same number is being compared with itself

C Programming Language by K.V.Ramana M.Tech Naresh Technologies 28

You might also like