You are on page 1of 10

GURU GOBIND SINGH COLLEGE FOR MTMS

AL – 7 Main Jail Road, Hari Nagar, New Delhi – 110064

C Programming
Q.1. BCPL stands for
(a)Basic computer programming language
(c) basic common programming language
(b)basic combined programming language
(d)none of these

Q.2 The start point of a program is


(a)header file (c)main function
(b)preprocessor directive (d)variable declaration

Q.3 This is used to show the start & end point of a function
(a) curly brackets (c)round brackets
(b)square brackets (d)none of these

Q.4 Printf is a --------function


(a)predefined (c)user defined
(b)standard (d)library

Q.5 # include <stdio.h>allows the program to interact with the


(a) Key board (c) file system
(b) Screen (d) all of these

Q.6 In C, one can specify their constants in octal or hexadecimal, or force them
to be treated as ______
(a)integer (c)double
(b)long integer (d)char

Q.7 Select the wrong declaration


(i) int a=10,b,c;
(ii) int a=10,float b=5.0;
(iii) long int a;
(iv) char a[-10];
(a) (I) only (c) (iv) only
(b) (ii) only (d) (ii) & (iv)

Q.8 C provide ---- classes to store integer value


(a)1 (c)3
(b)2 (d)4

Q.9 By default, the precision in floating values


(a)4 digits (c)5 digits
(b)3 digits (d)6 digits

Ph. 9810455330, 25138338, 25138339


GURU GOBIND SINGH COLLEGE FOR MTMS
AL – 7 Main Jail Road, Hari Nagar, New Delhi – 110064

Q.10 The range of a double is


(a)3.4 E-308 to 3.4E+308 (c)1.9 E-308 to 1.9 E +308
(b)2.6E-308 to 2.6 E+308 (d)1.7 E-308 to 1.7 E +308

Q.11 This is not a real data type


(a)int (c)char
(b)long int (d)double

Q.12 This is not a structured data type is C


(a) Union (c)Boolean
(b) Pointer (d) struct

Q.13 This data type is used to declare variables that can have one of the value
enclosed with in braces
(a) enum (c)array
(b)struct (d)union

Q.14 Which of these is a valid variable name


(a)_x1 (c)name
(b) sqrt (d)123

Q.15 A global variable is declared


(a)before the main( ) (c)before the header files
(b)after the preprocessor directives (d)both (a) & (b)

Q.16 What will be the output of the following program


Main ( )
{
fun ( );
fun ( );
fun( );
}
fun ( )
{
static int i=0;
I = I+1;
printf ( “%d”, I );
}
(a)0,1,2 (c)1,2,3
(b)0,0,0 (d)1,1,1

Q.17 A group of related data items that share a common name, is known as
(a)array (c)structure
(b)pointer (d)union

Ph. 9810455330, 25138338, 25138339


GURU GOBIND SINGH COLLEGE FOR MTMS
AL – 7 Main Jail Road, Hari Nagar, New Delhi – 110064

Q.18 If an array is declared as int num[10],then its index will be from


(a)0 to 9 (c)1 to 9
(b)0 to 10 (d)1 to 10

Q.19 Which of these is a correct method of declaring a 2 dimensional array?


(a) int num[2,3]={{50,60},{60,70},{70,80}}
(b) int num[2,3]={50,60,60,70,70,80}
(c) int num[2,3]={{50,60,70},{60,70,80}}
(d) all of these

Q.20 When an array is passed as an argument to a function one more argument


you have to pass with the array is
(a)elements of the array (c)data type of the array
(b)size of the array (d)none of these

Q.21 In C, when division is preformed between 2 integers, the result will be an


(a)float (c)double
(b)integer (d)both (a)&(b)

Q.22 This statement will convert a lower case letter into upper case letter
(a) x = x +’B’-‘b’ (c) x = x +’A’-‘a’
(b) x = x+ ’C’-‘c’ (d) all of these

Q.23 How many relational operators are there provided by C?


(a)5 (c)7
(b)6 (d)8

Q.24 Find out the output of the following statements


A=4; b=6;
X=(++a)+ (b++)
(a)x=10 (c) x=11
(b) x=9 (d) x=12

Q.25 If a=14 and b=6, what will be the x=a &b;


(a)x=6 (c) x=15
(b)x=14 (d) x=7

Q.26 What will be the output of 3<<2


(a)6 (c)2
(b)12 (d)3

Q.27 The one’s complement of decimal 10 is


(a)-10 (c)-5
(b)5 (d)10

Ph. 9810455330, 25138338, 25138339


GURU GOBIND SINGH COLLEGE FOR MTMS
AL – 7 Main Jail Road, Hari Nagar, New Delhi – 110064

Q.28 Which of these an valid expression


(a)x=(a=2,b=3,a+b) (c)x=(a=2,b=3;a+b)
(b)x=(a=2;b=3;a+b) (d)none of these

Q.29 Among the following, which precedence order is correct?


(a)structure access, logical OR, bitwise AND, comma
(c)Shift right, comma ,Logical OR, conditional expression
(b)modulus, bitwise AND, logical OR, assignment
(d)assignment, shift left, not equal, unary

Q.30 In switch case, one variable is tested for all condition. This variable should
be of ---------type
(a) integral (c) integer
(b)float (d) array

Q.31 What will be the output of the following program the input is 2
Switch(num)
{
case 0: printf (“0”);
case 1: printf (“1”);
case 2: printf (“2”);
case 3: printf (“3”);
default: printf (“*”);
}
(a)23* (c)2
(b)2 3 (d)0123*

Q.32 In goto statement , _______ is used with each label


(a)colon (c)asterisk
(b)semicolon (d)exclamation

Q.33 In a string, it is used to show the end of string


(a)NULL (c)/0
(b)\0 (d) eof

Q.34 With printf function, ----- is used to print a hexadecimal value


(a)%hd (c)%u
(b)%h (d)%l

Q.35 Which of these is an invalid for loop statement


(a)for(I=0,j=0;I<10;I++) (c)for (I=0,j=0; I<10,j<10;I++,j++)
(b)for(I=0,j=0;I<10;I++,j++) (d)none of these

Ph. 9810455330, 25138338, 25138339


GURU GOBIND SINGH COLLEGE FOR MTMS
AL – 7 Main Jail Road, Hari Nagar, New Delhi – 110064

Q.36 In C, nesting of for loop can continue up to ------------- levels.


(a)5 (c)15
(b)10 (d)20

Q.37 ASCII NULL has the value


(a)0 (c)-1
(b)1 (d)not defined

Q.38 EOF can be generated by typing ----- on keyboard


(a)ctrl +d (c)ctrl +x
(b)ctrl +c (d)ctrl +e

Q.39 If declared size of the string is 4, & the entered string is “manipal” ,then its
printed value will be
(a) manipal (c) manip
(b) mani (d)error

Q.40 The prototype for gets ( )function is


(a)char *gets(char buffer) (c)char gets(char *buffer)
(b)char gets(char buffer) (d)char *gets(char *buffer)

Q.41 To get the address of a variable & to store the address of that variable,
___and ____is used.
(a)&,pointer (c)pointer, &
(b)&,** (d)&&,*

Q.42 The prototype for fputs function is defined as


(a)int fputs(const char *buff, file *fp) (c)int fputs(const char buff, file * f p)
(b)int fputs (const char *buff, file f p) (d)int fputs(const char buff, file f p)

Q.43 Encapsulation is --------hiding


(a)data (c)detail
(b)information (d)all of these

Q.44 In C, this type of function is provided


(a)function with no argument, no return value
(c)function with argument, no return value
(b) function with no argument, with return value
(d)function with argument, with return value
(e)all of these

Q.45 When a function dose not return a value, ___ is used


(a)null (c)return 0
(b)void (d)none

Ph. 9810455330, 25138338, 25138339


GURU GOBIND SINGH COLLEGE FOR MTMS
AL – 7 Main Jail Road, Hari Nagar, New Delhi – 110064

Q.46 To display an error is used


(a)error _line (line_no) (c)error _line(error _no)
(b)error_ line(error _type) (d)error_line ( )

Q.47 What will be the output of the following program


Swap(int a, int b)
{
int t;
t=a; a=b; b=t;
}
main ( )
{
int x=3, y=4;
swap(x, y);
print f (“%d %d; x, y);
}
(a)3,3 (c)3,4
(b)4,4 (d)4,3

Q.48 This function appends a source string to the end of a destination string
(a) strcat (c)strncat
(b) strcpy (d)strncpy

Q.49 In the strcmp function, if the first string is smaller than the second string,
then it return a number
(a)greater then zero (c)less than zero
(b)equal to zero (d)not equal to zero

Q.50 The prototype for strncat function is


(a)char *strncat(char *dst, const char*src, size t n);
(b)char *strcat(char dst, const char * src);
(c)char *strcat (char *dst, const char src, size_t n);
(d)char *strncat(char dst, const char src, size_t n);

Q.51 The prototype for memset is


(a)void *memset(const void *dst, char C, size _t n);
(b) int *memset(const void *dst, char C, size _t n);
(c) void *memset(const void *dst, int C, size_t n);
(d) int * memset(const void *dst, int C, size_t n);

Q.52 A structure name is also known as the


(a)type def (c)struct
(b)structure tag (d)tag

Ph. 9810455330, 25138338, 25138339


GURU GOBIND SINGH COLLEGE FOR MTMS
AL – 7 Main Jail Road, Hari Nagar, New Delhi – 110064

Q.53 This can be passed to a function as an argument


(a)pointer (c)structure
(b)array (d)all of these

Q.54 If we have to store a complex number in C, we will use


(a)pointer (c)structure
(b)array (d)int

Q.55 A stream is a source or destination of data. It may be a


(a)buffer in memory (c)a hardware device
(b)a file (d)all of these

Q.56 Fprintf returns ------ if successful or a negative number on failure


(a)one (c)no. of characters read
(b)no. of characters written (d)zero

Q.57 To read data from a character buffer ----- is used


(a)fscanf (c)sscanf
(b)scanf (d)fgets

Q.58 The prototype for fputs is


(a)int fputc( char C, file *stream); (c)char fputc (char C, file *stream);
(b)int fputc(int C, file *stream); (d)char fputc(int C, file *stream);

Q.59 Fopen takes 2 arguments, & the datatype of arguments are


(a)string, string (c)int, string
(b)string, int (d)int,int

Q.60 ---------- puts formatted data into a string which must have sufficient space
allocated to hold it
(a) printf (c) sprintf
(b) fprintf (d) ssprintf

Q.61 If a file is open in r+ mode, then the file used is for


(a)read (c)both (a)&(b)
(b)append (d)none

Q.62 Fread takes _________ arguments


(a)1 (c)4
(b)2 (d)3

Q.63 Memory allocation provides a way dynamically create


(a)int pointer (c)null pointer
(b)char pointer (d)void pointer

Ph. 9810455330, 25138338, 25138339


GURU GOBIND SINGH COLLEGE FOR MTMS
AL – 7 Main Jail Road, Hari Nagar, New Delhi – 110064

Q.64 Char data is stored in


(a)1 byte (c)3 bytes
(b)2 byte (d)4 bytes

Q.65 Sizeof(long) will return


(a) (c)
(b) (d)

Q.66 On successful memory allocation, malloc() returns a


(a) int pointer (c)null pointer
(b)char pointer (d)void pointer

Q.67 Passing zero as second argument to realloc() function is equivalent of


calling
(a) malloc (c) free
(b) calloc (d) none of these

Q.68 A directive starts with a ---------- symbol.


(a)$ (c)@
(b)# (d)*

Q.69 In C, the preprocesses is called _________


(a) c (c) cpp
(b) pp (d) ppc

Q.70 Macros are also known as _________


(a)abstraction (c)polymorphism
(b) encapsulation (d)functions

Q.71 File inclusion directives are used with ___ brackets


(a)angle (c)square
(b)round (d)curly

Q.72 This is not a keyword in C


(a)unsigned (c)short
(b)done (d)auto

Q.73 Scanf function is not used with this format string


(a)%u (c)%o
(b)%x (d)%lf

Ph. 9810455330, 25138338, 25138339


GURU GOBIND SINGH COLLEGE FOR MTMS
AL – 7 Main Jail Road, Hari Nagar, New Delhi – 110064

Q.74 (i) # define M 5


(ii) #define SQ(M) (M*M)
(iii) # define MAX(a, b) (a>b ?a :b)
which of the above declaration is wrong
(a) (i) (c) (iii)
(b) (ii) (d) none

Q.75 What will be the value of I


Int i=40,*p,*q;
P=&i; q=p;
I=*p++ + ++(*q);
(a)4 (c)8
(b)5 (d)9

Q.76 If an array is declared as


X[2][3] = {{3,2,1},{6,5,4}}
Then what will be the output of following –
(i) *(*x + 1)
(a) 1 (c) 3
(b) 2 (d) 4

(ii) *(*( x+1)+1)


(a)2 (c) 4
(b)3 (d) 5

(iii) *(*(x+1)+2)
(a)3 (c) 5
(b)4 (d) 6

(iv) *(*x+3)
a) 6 (c) 4
(b) 5 (d) 3

(v) *(*(x+0))
(a) 1 (c) 5
(b) 3 (d) 0

Ph. 9810455330, 25138338, 25138339


GURU GOBIND SINGH COLLEGE FOR MTMS
AL – 7 Main Jail Road, Hari Nagar, New Delhi – 110064

Q.77 What will be the output of the following program


Main()
{
# if DM==1
printf(“VALUE 1”);
#elif DM=2
printf(“VALUE 2”);
#elif DM>2
printf(“VALUE 3”);
#else
printf(“DEFAULT”);
#endif
}
(a) VALUE 1 (c) VALUE 3
(b) VALUE 2 (d) VALUE 4

Ph. 9810455330, 25138338, 25138339

You might also like