Uploaded by padhyarpita02

CFT Final 1st topic

advertisement
C Fundamental Test-1
1) Which of the following is the first operating system developed using C
programming language?
 Windows
 DOS
 Mac
 UNIX
Explanation:
C programming language is invented for developing an operating system called UNIX. By 1973, the
complete UNIX OS is developed using C.
2) The C compiler used for UNIX operating system is
 cc
 gcc
 vc++
 Borland
Explanation:
Compiler used for UNIX is 'cc' their full form is C compiler. gcc is compiler for linux. Borland and vc++ is
compiler for windows.
3) Which of the following is a logical AND operator?
 ||
 !
 &&
 None of the above
Explanation:
The && is called logical AND operator. If both operands are non-zero, then the condition becomes true.
The || is called logical OR operator. If any of the two operands are non-zero, then the condition becomes
true.
The ! is called logical NOT operator. It is used for reversing the logic state of its operand.
4) Which format specifier is used for printing double value?
 %Lf
 %L
 %lf
 None of the above
Explanation:
The %lf format specifier is used for printing the double value in a C program.
5) Which of the following statement is used to free the allocated memory space
for a program?
 vanish(var-name);
 remove(var-name);
 erase(var-name);
 free(var-name);
Explanation:
The memory allocated by malloc(), calloc(), or realloc() function is deallocated by using the library function
free(var-name).
C Fundamental Test-2
6) In a library of C programming language, which of the following header file is
used for performing mathematical operations?
 conio.h
 dos.h
 math.h
 stdio.h
Explanation:
"math.h" is a header file used for performing mathematical operation in a library of C programming
language.
7) What are the various types of real data type in C language?
 long double, short int
 float, long double
 short int, double, long int, float
 float, double, long double
Explanation:
Floating data type is known as real data type.
There are three types of floating data type:
o float with storage size of 4 byte
o long double with storage size of 10 byte
o double with storage size of 8 byte
8) The statement used for printing \n on the screen is:
 printf("");
 printf('\n');
 printf("\\n");
 printf("n\");
Explanation:
In C language,"\n" is the escape sequence for printing a new line character. For a statement printf("\\n");
statement , "\\" symbol will be printed as "\" and "n" is known as a common symbol.
9) Which of the following are declarations?
1. float square (float x){?}
2. double pow(double, double);
3. extern int x;
Explanation:
double pow(double, double); instruction is a function prototype declaration
extern int x; instruction is an external variable declaration.
Therefore 1 and 3 are declarations and 2 is definition.
10) Which header file is used to define input/output functions, macros and
prototypes?
 memory.h
 math.h
 dos.h
 stdio.h
Explanation:
Header file stdio.h is used for defining the macros, variable and various functions for performing input and
output operation in C-language.
C Fundamental Test-3
11) Single line comment in C language begins with _______
 :
 //
 */
 /*
Explanation:
For giving the comment in single line two immediate forward slashes are used. For a multi line
comment it begins with /* and should be terminated with */.
12) What is the data type of "PI" for the below statement:
#define PI 3.141
 Float data type
 Double datatype
 There is no data type associated with PI
 Syntax error, semi colon is missing with definition of PI
Explanation:
Text associated with macro statement gets expanded at line of call. The expanded text is by
default a constant with no data type associated with PI.
13) Which operator can be used for accessing the value stored at address
of a pointer variable?
 #
 *
 &&
 @
Explanation:
The pointer operator is,
& (address operator) = It gives address of the variable
*(Value operator) = It gives value stored at particular address
14) The types of linkages in C programming language are:
 External linkage and None linkage
 Internal linkage and None linkage
 Internal linkage, External linkage and None linkage
 Internal linkage and External linkage
Explanation:
o Internal linkage: A functions and static variables with file scope.
o External linkage: A global, functions and non-static variables.
o None linkage: A local variables.
15) Which of the following is true about C Programming?
 Platform Independent
 High level language
 Machine Independent
 Assembly language
Explanation:
C-programming language is machine independent programming language. It provides the feature
of portability of code means source code written on one machine can be run on any other
machines.
C Fundamental Test-4
16) What is the correct value returned to the operating system upon
successful completion of a program?
 0
 -1
 1
 Programs do not return a value
Explanation:
After successful completion of a program, 0 is returned to the operating system.
17) Who is known as the founder of C language?
 James Gosling
 Martin Richard
 Brian Kernighan
 Dennis Ritchie
Explanation:
The C programming language has been developed by Dennis Ritchie in the year 1972 while
working at AT&T Bell Laboratories.
18) The C variables are case insensitive.
 True
 False
Explanation:
The C variables are case sensitive. This means that variables sal, Sal and SAL would be treated
as different variables in C.
19) A character variable can store ___ character(s) at a time.
 1
 2
 0
 NULL
Explanation:
A character variable can at a time store only one character. In fact, if we execute the following
statements, what gets stored in variable ch is not really the character constant, but the ASCII
value of 'A', which is 65.
char ch;
ch= 'A';
20) How would you round off a value from 1.66 to 2.0?
 floor(1.66)
 ceil(1.66)
 roundup(1.66)
 roundto(1.66)
Explanation:
The ceil(1.66) is used for round off a value from 1.66 to 2.0. The ceil() returns upper value
of a fractional part and floor() returns lower value.
#include<stdio.h>
#include<math.h>
void main()
{
printf("\n Result : %f" , ceil(1.44) );
printf("\n Result : %f" , ceil(1.66) );
printf("\n Result : %f" , floor(1.44) );
printf("\n Result : %f" , floor(1.66) );
}
Output:
Result : 2.000
Result : 2.000
Result : 1.000
Result : 1.000
Download