Page 1 :
C Programming MCQ Questions and Answers, BASIC SET-1, 1) Who invented C Language.?, A) Charles Babbage, B) Grahambel, C) Dennis Ritchie, D) Steve Jobs, Answer [=], , C, Explanation:, Full name is Dennis MacAlistair Ritchie. He also invented Unix Operating System along with his colleague, Ken Thomson., , 2) C Language is a successor to which language.?, A) FORTRAN, B) D Language, C) BASIC, D) B Language, Answer [=], , D, , 3) C is a which level language.?, A) Low Level, B) High Level, C) Low + High, D) None, Answer [=], , B, Explanation:, C is a high level language. Another example is BASIC., , 4) Low level language is .?, A) Human readable like language., B) language with big program size., C) language with small program size., D) Difficult to understand and readability is questionable., Answer [=], , D, Explanation:, Looks like raw data often in the form of 1's and 0's., , 5) High level language is a .?, A) Human readable like language., B) language with small program size.
Page 2 :
C) language with big program size., D) language which is difficult to understand and not human readable., Answer [=], , A, Explanation:, Examples are C and BASIC., , 6) Which program outputs "Hello World.." .?, A), main(), {, scanf("Hello World..");, }, B), main(), {, printf("Hello World..");, }, C), main(), {, print("Hello World..");, }, D), main(), {, scan("Hello World..");, }, Answer [=], , B, , 7) C is _______ type of programming language.?, A) Object Oriented, B) Procedural, C) Bit level language, D) Functional, Answer [=], , B, Explanation:
Page 3 :
C is a procedural language. It is written in a number of steps using statements and functions. Logic is, clearly depicted in the program. Procedural language is aslo called Imperative Language. Examples are, COBAL, BASIC etc., , 8) What is the present C Language Standard.?, A) C99 ISO/IEC 9899:1999, B) C11 ISO/IEC 9899:2011, C) C05 ISO/IEC 9899:2005, D) C10 ISO/IEC 9899:2010, Answer [=], , B, , 9) What are the new features of C11 or ISO IEC 9899 2011, standard.?, A) Type generic Macros, Static Assertions, B) Multi Threading, Anonymous Unions, quick_exit, C) Bounds Checking Interfaces, Anonymous Strurctures, D) All, Answer [=], , D, , 10) C language was invented in which laboratories.?, A) Uniliver Labs, B) IBM Labs, C) AT&T Bell Labs, D) Verizon Labs, Answer [=], , C, Explanation:, C was invented in Bell Laboratories in New Jersey., , 11) BCPL Language is also called..?, A) C Language, B) B Language, C) D Language, D) None, Answer [=], , D, Explanation:, B language is successor of BCPL ( Basic Combned Programming Language ). B language was invented by, Ken Thomson., , 12) C language was invented to develop which Operating System.?, A) Android, B) Linux, C) Ubuntu, D) Unix, Answer [=], , D, Explanation:
Page 4 :
C was invented to develop Unix Operating System to overcome compatibility with different Hardware, Platforms., , 13) C language was invented in the year.?, A) 1999, B) 1978, C) 1972, D) 1990, Answer [=], , C, , 14) C language is used in the development of .?, A) Databases, B) Graphic applications, C) Word Processors, D) All of the above, Answer [=], , D, Explanation:, C language is very efficient in using hardware resources., , 15) A C program is a combination of.?, A) Statements, B) Functions, C) Variables, D) All of the above, Answer [=], , D, , SET-2, 1) Choose correct answer.., #include<stdio.h>, main(), {, /* Multi Line Comment, This line is ignored by compiler, */, printf("Hello C..");, }, , A) #include is a Preprocessor Directive
Page 5 :
B) <stdio.h> is a header file with predefined functions like printf, scanf etc, C), #include, main(), {, , }, is a mandatory function to be included in every C Program., , D) All the above, Answer [=], , D, 2) Correct way of commenting a single line is.?, A) /*printf("Hello C.."); printf("How are you.");, B) //printf("Hello C.."); printf("How are you.");, C) /*printf("Hello C.."); printf("How are you.");*/, D) /printf("Hello C..");/ printf("How are you.");, Answer [=], , B, Explanation:, Answer C comments two lines with Multi-Line comment or BLOCK, Comment characters /* ....*/, Only // is a Single Line Commenting characters., 3) Single Line Comment // is also called.?, A) C++ Style Comment, B) Java Style Comment, C) PHP Style Comment, D) All the above, Answer [=], , D, 4) Choose the correct answer.?, A) Digraph <: represents [ Digraph :> represents ] Digraph <% reprsents {, Digraph %> reprsents } Digraph %: represents # Digraph %:%: represents ##, B) Digraph <: represents ] Digraph :> represents [ Digraph <% reprsents {, Digraph %> reprsents } Digraph %: represents # Digraph %:%: represents ##, C) Digraph <: represents ] Digraph :> represents [ Digraph <% reprsents }, Digraph %> reprsents { Digraph %: represents $ Digraph %:%: represents $$, D) Digraph <: represents { Digraph :> represents } Digraph <% reprsents [, Digraph %> reprsents ] Digraph %: represents / Digraph %:%: represents //
Page 6 :
Answer [=], , A, Explanation:, Some keyboards in some countries do not contain Punctuation Keys., They have to use these Digraphs to represent the corresponding, characters., Eg., int ary[] = { 1, 2}; is written as int ary<::> = <%1, 2%>;, Trigraphs are also present to support 1991 standard of representing 7, bit characters. ??( represents [., 5) What is an Identifier in C Language.?, A) Name of a Function or Variable, B) Name of a Macros, C) Name of Structure or Union, D) All the above., Answer [=], , D, Explanation:, int age=25;, //here age is an Identifier, 6) An Identifier may contain.?, A) Letters a-z, A-Z in Basic character set. Unicode alphabet characters other, languages, B) Underscore _ symbol, C) Numbers 0 to 9 Unicode Numbers in other languages, D) All the above, Answer [=], , D, 7) What is the number of characters used to distinguish Identifier, or Names of Functions and Global variables.?, A) 31, B) 32, C) 33, D) 28, Answer [=], , A, Explanation:, First 31 characters in general. If first 31 characters are same for two, different identifiers, compiler gets confused.
Page 7 :
8) What is length of an Identifier that is unique for Non Global, Variables and Non Function Names.?, A) 32, B) 63, C) 64, D) 68, Answer [=], , B, Explanation:, if 31 is present choose. Because old compilers support up to 31 only., Upto first 63 characters you can show differentiation in the name of, say, int abcdefghijklmnopqrstuvwxyz1234567788= 10;, int abcdefghijklmnopqrstuvwxyz1234567799 = 20;, 9) An Identifier can start with.?, A) Alphabet, B) Underscore ( _ ) sign, C) Any character that can be typed on a keyboard, D) Option A & Option B, Answer [=], , D, Explanation:, Identifier is just a name given to a Function, Variable etc., Identifier name should contain only Letter, Numbers and Underscore., 10) C Programs are used in .?, A) Any Electronic device which works on some logic and Operating System., B) Washing machine, C) Fridge, Microwave Ovens, D) All the above., Answer [=], , D, Explanation:, C is very fast to execute and safe to embed along with microprocessors., Device drivers are written in C and C++., 11) What are the types of Constants in C Language.?
Page 8 :
A) Primary Constants, B) Secondary Constants, C) Basic Constants and Advanced Constants, D) Primary Constants and Secondary Constants, Answer [=], , D, Explanation:, Primary Constants are Integer (int), Floating Point (float) , Character, (char), Secondary Constants are Structure, Union, Array and Enum., 12) Choose correct statements, A) A constant value does not change. A variable value can change according to, needs., B) A constant can change its values. A variable can have one constant value only., C) There is no restriction on number of values for constants or variables., D) Constants and Variables can not be used in a singe main function., Answer [=], , A, Explanation:, Constant value is always constant. Constant is also called Literal., Variable can have any number of arbitrary values and once value at any, point of time. Variable is also called Identifier., 13) Find an integer constant., A) 3.145, B) 34, C) "125", D) None of the above, Answer [=], , B, Explanation:, Integer constant is a full or whole number without any decimal point., So 3.14 is a floating point number or Real number., 14) Find a Floating Point constant., A) 12.3E5, B) 12e34, C) 125.34857, D) All the above., Answer [=], , D, Explanation:
Page 9 :
Floating Point can be represented in two forms., 1. Fractional Form, eg. 12345.67, 2. Exponential Form, (Mantissa)e(number) or (Mantissa)E(number), eg. 123.4567E2, (e2 = 10 power 2 = 100), , 15) Find a Character constant., A), 'A', 'a', , B), '1', '9', , C), '$', '#', , D) All the above., Answer [=], , D, Explanation:, A character constant contains only one character within Single Quotes. ', '. Single Quote is typed using Single Quote Double Quote Key near Enter, Key in a Keyboard. Simply it is Right Single Quote., Left Single Quote looks like this `, Right Single Quote looks like this ', 16) A Variable of a particular type can hold only a constant of, the same type. Choose right answer., A) TRUE, B) FALSE
Page 10 :
C) It depends on the place the variable is declared., D) None of the above., Answer [=], , A, Explanation:, An int can hold only Integer constant., A float can hold only Real Number constants., A char can hold only Character constants., 17) Choose a, A) int myage =, B) int myage =, C) int myage =, D) All are right, , right statement., 10; int my_age = 10;, 10; int my,age = 10;, 10; int my age = 10;, , Answer [=], , A, Explanation:, Only Underscore ( _ ) symbol is allowed in a variable name i.e identifier, name. Space, Comma and other special characters are not allowed., 18) Number of Keywords present in C Language are .?, A) 32, B) 34, C) 62, D) 64, Answer [=], , A, Explanation:, Only 32 Keywords originally. Compilers are individual companies can, include and use extra keywords if required. Such keywords should, preceed with __ ( two Underscore symbols before names)., eg. __mykeyword, 19) Each statement in a C program should end with.?, A) Semicolon ;, B) Colon :, C) Period . (dot symbol), D) None of the above., Answer [=], , A, Explanation:, e.g
Page 11 :
int amount = 10;, float a,b;, 20) Choose a correct statement., A) C Compiler converts your C program into machine readable language., B) C Editor allows you to type C Programs. It is just like a Notepad with extra, options., C) Console shows the output of a C Program if it is text output., D) All the above, Answer [=], , D, , DATA TYPE AND STORAGE CLASS, 1) Identify wrong C Keywords below., A) auto, double, int, struct, B) break, else, long, switch, C) case, enum, register, typedef, D) char, extern, intern, return, Answer [=], , D, Explanation:, 'intern' is not a keyword. Remaining are all valid keywords., 2) Identify wrong C Keywords below., A) union, const, var, float, B) short, unsigned, continue, for, C) signed, void, default, goto, D) sizeof, volatile, do, if, Answer [=], , A, Explanation:, 'var' is not a valid keyword., 3) Identify wrong C Keywords below., A) static, while, break, goto, B) struct, construct, signed, unsigned, C) short, long, if, else, D) return, enum, struct, do, Answer [=], , B, Explanation:
Page 12 :
construct is not a keyword., All 32 Keywords are given for reference. auto, break, case, char, const,, continue, default, do, double, else, enum, extern, float, for, goto, if, int,, long, register, return, short, signed, sizeof, static, struct, switch,, typedef, union, unsigned, void, volatile, while., 4) Find a correct C Keyword below., A) breaker, B) go to, C) shorter, D) default, Answer [=], , D, 5) Find a correct C Keyword below., A) work, B) case, C) constant, D) permanent, Answer [=], , B, 6) Find a correct C Keyword., A) Float, B) Int, C) Long, D) double, Answer [=], , D, Explanation:, All C Keywords are in lower case., 7) Types of Integers are.?, A) short, B) int, C) long, D) All the above, Answer [=], , D, Explanation:, Size of int < long.
Page 13 :
8) Types of Real numbers in C are.?, A) float, B) double, C) long double, D) All the above, Answer [=], , D, Explanation:, Size of float < double < long double, 9) signed and unsigned representation is available for.?, A) short, int, long, char, B) float, double, long double, C) A & B, D) None of the above, Answer [=], , C, Explanation:, Real numbers like float, double and long double do not support, unsigned representation., 10) Size of a Turbo C C++ compiler is.?, A) 16 bit, B) 32 bit, C) 64 bit, D) 128 bit, Answer [=], , A, 11) Size of a GCC or Visual Studio C Compiler is.?, A) 16 bit, B) 32 bit, C) 64 bit, D) 128 bit, Answer [=], , B, 12) Sizes of short, int and long in a Turbo C C++ compiler in, bytes are.?, A) 2, 2, 4, B) 2, 4, 4
Page 14 :
C) 4, 8, 16, D) 8, 8, 16, Answer [=], , A, 13) Sizes of short, int and long in Visual Studio or GCC compiler, in bytes are.?, A) 2, 2, 4, B) 2, 4, 4, C) 4, 4, 8, D) 4, 8, 8, Answer [=], , B, 14) Range of signed char and unsigned char are.?, A) -128 to +127 0 to 255, B) 0 to 255 -128 to +127, C) -128 to -1 0 to +127, D) 0 to +127 -128 to -1, Answer [=], , A, Explanation:, Advantage of an unsigned representation is only to increase the upper, limit i.e positive limit. Size of a char remains same i.e 1 Byte., , 15) Ranges of signed int and unsigned int are.?, A) 0 to 65535 -32768 to +32767, B) -32768 to +32767 0 to 65535, C) -32767 to +32768 0 to 65536, D) 0 to 65536 -32767 to +32768, Answer [=], , B, Explanation:, Default assumption is Turbo C/C++, 16 bit compiler. Size of an int is 2, bytes for both signed and unsigned representation., 16) Size of float, double and long double in Bytes are.?, A) 4, 8, 16, B) 4, 8, 10, C) 2, 4, 6, D) 4, 6, 8
Page 15 :
Answer [=], , B, Explanation:, Real numbers are represented in float, double and long double format., eg. float interest = 12.55f;, 17) Range of singed long and unsigned long variables are.?, A) -2147483647 to +2147483648 0 to 4294967295, B) -2147483648 to +2147483647 0 to 4294967296, C) -2147483648 to +2147483647 0 to 4294967295, D) 0 to 4294967295 -2147483648 to +2147483647, Answer [=], , C, Explanation:, Size of a long variable is 4 Bytes or 32 bits., (2)^32., 18) Range of float variable is.?, A) -3.2e38 to +3.2e38, B) -3.8e32 to +3.8e32, C) -3.4e34 to +3.4e34, D) -3.4e38 to +3.4e38, Answer [=], , D, Explanation:, e represents exponential., 19) Left most bit 0 in Singed representation indicates.?, A) A Positive number, B) A Negative Number, C) An Unsigned number, D) None of the above, Answer [=], , A, Explanation:, For negative numbers 1 is used as a left most bit., 20) If you do not specify a storage class for a Variable.?, A) You get compiler error., B) You get a compiler warning., C) Output is null always, D) None of the above, Answer [=], , D
Page 16 :
Explanation:, Yes. Even if you do not specify a Storage class for a Variable,, AUTOMATIC storage class is applied., , SET-2, 1) What is a C Storage Class.?, A) C Storage decides where to or which memory store the variable., B) C Storage Class decides what is the default value of a variable., C) C Storage Class decides what is the Scope and Life of a variable., D) All the above., Answer [=], , D, 2) Every C Variable must have.?, A) Type, B) Storage Class, C) Both Type and Storage Class, D) Either Type or Storage Class, Answer [=], , C, Explanation:, Yes. A C Variable should have both Type and Storage Class., Eg., int a=5; //By default its Storage Class is auto., auto int b=10;, , 3) Find a C Storage Class below., A) static, B) auto, C) register & extern, D) All the above, Answer [=], , D, 4) What is the default C Storage Class for a variable.?, A) static, B) auto
Page 17 :
C) register, D) extern, Answer [=], , B, Explanation:, int a=5; // auto is by default, auto int b=10; // storage class auto is explicitly mentioned., , 5) Choose a right answer., A) auto variable is stored in 'Memory'. static variable is stored in 'Memory'. extern, variable is stored in 'Memory'. register variable is stored in 'Memory'., B) auto variable is stored in 'Memory'. static variable is stored in 'Memory'. extern, variable is stored in 'Memory'. register variable is stored in 'Register'., C) auto variable is stored in 'Register'. static variable is stored in 'Register'. extern, variable is stored in 'Register'. register variable is stored in 'Memory'., D) auto variable is stored in 'Register'. static variable is stored in 'Register'. extern, variable is stored in 'Register'. register variable is stored in 'Register'., Answer [=], , B, Explanation:, Only a register variable is stored in CPU Memory called Registers. Other, variables are stored in RAM., 6) A register variable is stored in a Register. Where does a, Register Present in a Computer.?, A) RAM ( Random Access Memory ), B) ROM ( Read Only Memory ), C) CPU (Central Processing Unit ), D) DMA ( Direct Memory Access ), Answer [=], , C, Explanation:, Yes. Registers are part of a CPU to store variable whose value changes, frequently. Loop variables for example., , register int i=1;, while(i <= 10), {, printf("i=%d\n", i);, }
Page 18 :
7) Variables of type auto, static and extern are all stored in .?, A) ROM, B) RAM, C) CPU, D) Compiler, Answer [=], , B, , 8) Find a right answer., A) Default value of auto variable = Garbage Value Default value of static =, Garbage Value Default value of extern = Garbage Value Default value of register, = Garbage Value, B) Default value of auto variable = zero Default value of static = zero Default, value of extern = zero Default value of register = zero, C) Default value of auto variable = Garbage Default value of static = zero Default, value of extern = zero Default value of register = Garbage, D) Default value of auto variable = zero Default value of static = Garbage Default, value of extern = Garbage Default value of register = zero, Answer [=], , C, 9) Find a correct statement., A) Scope of auto variable = local to block or function Scope of register variable =, local to block or function Scope of static variable = local to block or function, Scope of extern variable = global or available to all functions and blocks, B) Scope of auto variable = global or available to all functions and blocks Scope, of register variable = global or available to all functions and blocks Scope of static, variable = global or available to all functions and blocks Scope of extern variable, = local to block or function, C) Scope of auto variable = global or available to all functions and blocks Scope, of register variable = local to block or function Scope of static variable = global, or available to all functions and blocks Scope of extern variable = local to block or, function, D) Scope of auto variable = local to block or function Scope of register variable, = global or available to all functions and blocks Scope of static variable = local to, block or function Scope of extern variable = global or available to all functions, and blocks, Answer [=], , A
Page 19 :
10) Choose a correct statement., A) Life of an auto variable = persists between function calls Life of an register, variable = with in the block or function Life of an static variable = persists, between function calls Life of an extern variable = until program ends, B) Life of an auto variable = persists between function calls Life of an register, variable = until program ends Life of an static variable = persists between, function calls Life of an extern variable = with in the block or function, C) Life of an auto variable = until program ends Life of an register variable = until, program ends Life of an static variable = until program ends Life of an extern, variable = until program ends, D) Life of an auto variable = with in the block or function Life of an register, variable = with in the block or function Life of an static variable = persists, between function calls Life of an extern variable = until program ends, Answer [=], , D, 11) Which among the following is a Local Variable.?, A) register, B) auto, C) static, D) extern, Answer [=], , B, 12) Which among the following is a Global Variable.?, A) auto, B) register, C) static, D) extern, Answer [=], , D, Explanation:, #include<stdio.h>, #include<myutils.c>, void myshow();, int a=10; // a is a global variable., //Notice that there is no 'extern' keyword., void main(), {, printf("a=%d ", a);
Page 20 :
a = a + 1;, myshow();, show();, , }, , void show(), {, printf("a=%d ", a);, }, , //myutils.c file, //here we used extern to inform compiler, //about possible definition somewhere, extern int a;, void myshow(), {, printf("a=%d ", a);, a++;, , }, , //Output is 10 11 12, , 13) Choose a correct statement about static variable., A) A static global variable can be accessed in other files., B) A static global variable can be used only in a file in which it is declared., C) A static global variable can not be declared without extern keyword., D) Default value of a static variable is -1., Answer [=], , B, Explanation:, #include<stdio.h>, static int a=15;, void myshow();
Page 21 :
int main(), {, printf("%d", a);, myshow();, return 0;, }, , //myutils.c file, extern int a;, void myshow(), {, printf("%d", a);, }, , //Compiler error., //You can not use static global varible outside of file, , 14), register float a = 3.14f;, , Choose right statement., A) Variable a is stored in CPU registers for fast access., B) Variable a is converted to int and then stored in a CPU register., C) register Storage Class is ignored and treated as, auto float a = 3.14f;, , D) You get a compiler error as you can not store non integer value in a CPU, register., Answer [=], , C, Explanation:, Yes. CPU register can not store anything more than 16 bits or 2 bytes., You will not any compiler errors. It will be treated just like an auto, Storage Class variable.
Page 22 :
15) What is the difference between Declaration and Definition.?, A) Declaration does allocate memory for a variable. Definition does allocate, memory for a variable., B) Declaration does allocate memory for a variable. Definition does not allocate, memory for a variable., C) Declaration does not allocate memory for a variable. Definition does allocate, memory for a variable., D) Declaration does not allocate memory for a variable. Definition does not, allocate memory for a variable., Answer [=], , C, Explanation:, int a; //Definition. Allocates memory., , extern int b; //Does not allocate memory., , 16) Choose a right statement., A) A non static global variable can not be used in included files., B) A non static global variable can be used or referred to inside included files., C) A non static global variable does not live till the end of program execution., D) None of the above, Answer [=], , B, 17) Choose a right statement., A) Redeclaration of a variable is Ok., B) Redefinition of a variable is not Ok., C) Definition of a variable uses memory blocks., D) All the above., Answer [=], , D, 18) Choose a correct statement., A) Register variables are usually fast retrieving variables., B) Static variables are usually maintain their values between function calls., C) Auto variables release their memory after the block or function where they are, declared., D) All the above., Answer [=]
Page 23 :
D, 19) Choose a right statement., A) Variables of type auto are stored in Stack memory., B) Variable of type Static are stored in Segmented Memory., C) Variables of type register are stored in Micro Processor Memory., D) All the above., Answer [=], , D, 20) Choose a right statement., A) Variables of type auto are initialized fresh for each block or function call., B) Variables of type static are initialized only first time the block or function is, called., C) Variables of type register are initialized each time the block or function is, executed., D) All the above., Answer [=], , D, , SET-3, 1) Choose a correct statement regarding automatic variables., A) #include<stdio.h>, main(), , {, auto int a;, , printf("%d", a);, }, , //output is compiler error. a is not initialized., , B) #include<stdio.h>, main(), , {, auto int a;
Page 24 :
printf("%d", a);, }, , //output = 0, , C) #include<stdio.h>, main(), , {, auto int a;, , printf("%d", a);, }, , //output = null, , D) #include<stdio.h>, main(), , {, auto int a;, , printf("%d", a);, }, , //output = some random number, Answer [=], , D, Explanation:, Yes. If an integer is not initialized, some random number in integer, range will be displayed., 2) What is the output of the program.? #include<stdio.h>, int main(), {
Page 25 :
printf("Hello Boss.");, }, , A) Hello Boss., B) hello boss, C) No output, D) Compiler error, Answer [=], , D, Explanation:, Notice the return type int before main() method. So main should, maintain a return 0; or return somenumber; statement., 3) What is the output of the program.?, int main(), {, auto int a=10;, {, auto int a = 15;, printf("%d ", a);, }, printf("%d ", a);, return 1;, }, , A) 10 10, B) 10 15, C) 15 10, D) Compiler error, Answer [=], , C, Explanation:, Automatic or Register variables have block scope and life. Most recent, definition takes precedence. {...} is a block., 4) What is the output of the program.?, int main(), {, register a=10;, {
Page 26 :
register a = 15;, printf("%d ", a);, }, printf("%d ", a);, , return 20;, }, , A) 15 20, B) 15 10, C) 10 15, D) 15 15, Answer [=], , B, Explanation:, Automatic and Register variables have only Block Scope. Always local, definition takes precedence., 5) What is the output of the C Program statement.?, register int b;, prinf("%d", b);, , A) null, B) 0, C) random integer number, D) random real number, Answer [=], , C, Explanation:, auto and register variables hold garbage values by default., 6) What is the output the program.?, int main(), {, register a=80;, auto int b;, b=a;, printf("%d ", a);, printf("%d ", b);
Page 27 :
return -1;, }, , A) Compiler error. You can not assign register value to int variable., B) 80 80, C) 80 0 Register value can not be copied., D) Compiles, but output is none., Answer [=], , B, 7) What is the output of the program.?, void myshow();, , int main(), {, myshow();, myshow();, myshow();, }, , void myshow(), {, static int k = 20;, printf("%d ", k);, k++;, }, , A) 20 20 20, B) 20 21 21, C) 20 21 22, D) Compiler error., Answer [=], , C, Explanation:, Variable of type static holds its value until the end of program, execution. Static variables do not initialize again and again with, function calls.
Page 28 :
8) What is the output of the program.? #include<stdio.h>, static int k;, , int main(), {, printf("%d", k);, , return 90;, }, , A) -1, B) 0, C) 90, D) Compiler error, Answer [=], , B, Explanation:, Default value of a static variable is zero by default., 9) What is the output of the program.?, int main(), {, register k = 25;, printf("%d", &k);, , return 90;, }, , A) prints of address of variable k., B) 25, C) 0, D) Compiler error, Answer [=], , D, Explanation:
Page 29 :
You can not use Ampersand & operator with a Register variable., Register is part of CPU and accessing it is not authorized., 10) The statement below is .....a, extern int p;, , A) Declaration, B) Definition, C) Initialization, D) None of the above, Answer [=], , A, Explanation:, Usually, most of the C statements with extern keyword are Declara, , ARITHMETIC OPERATORS, SET-1, 1) Choose a correct statement., int a = 12 + 3 * 5 / 4 - 10, , A) 12, 3, 5, 4 and 10 are Operators., increment operator., B) 12, 3, 5, 4 and 10 are Operands., operator., C) 12, 3, 5, 4 and 10 are Operands., assignment operator., D) 12, 3, 5, 4 and 10 are Operands., assignment operator., , +, -, * and / are Operands. = is an, +, -, * and / are Operators. = is decrement, +, -, * and / are Operators. = is an, +, -, * and / are Logical Operators. = is an, , Answer [=], , C, 2) Operator % in C Language is called.?, A) Percentage Operator, B) Quotient Operator, C) Modulus, D) Division, Answer [=]
Page 30 :
C, Explanation:, Operator % is called Modulus or Modular or Modulo Division operator in, C. It gives the reminder of the division., int a = 11%4;, Now a holds only 3 which is the reminder., 3) Output of an arithmetic expression with integers and real, numbers is ___ by default.?, A) Integer, B) Real number, C) Depends on the numbers used in the expression., D) None of the above, Answer [=], , B, Explanation:, Any arithmetic operation with both integers and real numbers yield, output as Real number only., 5 + 10.56 = 15.560000 which is a real number., 5 + 10.0 = 15.000000 is also a real number., 4) Choose a right statement., int a = 10 + 4.867;, , A) a = 10, B) a = 14.867, C) a = 14, D) compiler error., Answer [=], , C, Explanation:, a is an int variable. So 10+4.867 = 14.867 is truncated to 14 and, assigned to a., 5) Choose a right statement., int a = 3.5 + 4.5;, , A) a = 0, B) a = 7, C) a = 8, D) a = 8.0
Page 31 :
Answer [=], , C, Explanation:, 3.5 + 4.5 = 8.0 is a real number. So it is converted to downgraded to int, value. So a = 8., 6) Choose a right statement., float var = 3.5 + 4.5;, , A) var = 8.0, B) var = 8, C) var = 7, D) var = 0.0, Answer [=], , A, Explanation:, A float variable can hold a real number., 7) Choose right statement., int main(), {, float c = 3.5 + 4.5;, printf("%f", c);, , return 0;, }, , A) 8.0, B) 8.000000, C) 8, D) 7, Answer [=], , B, Explanation:, Float can print precision up to 6 digits. So 6 zeros will be shown if there, are no digits after decimal point., , 8) Choose a right statement.
Page 32 :
int main(), {, float c = 3.5 + 4.5;, printf("%d", (int)c);, , return 0;, }, , A) 8.0, B) 8.000000, C) 7, D) 8, Answer [=], , D, Explanation:, You are printing a float variable by type casting to int. So integer is, printed., int c = 3.5 + 4.5 also holds and prints 8., 9) Choose a right statement., int a = 5/2;, int b = 5.0/2;, int c = 5 / 2.0;, int d = 5.0/2.0;, , A) a = 2, b = 2, c = 2, d= 2, B) a = 2, b = 2.0, c = 2, d= 2.0, C) a = 2, b = 2.5, c = 2.5, d= 2.5, D) a = 2.5, b = 2.5, c = 2.5, d= 2.5, Answer [=], , A, Explanation:, Irrespective of numbers after decimal point, an int variable holds only, integer value i.e 2., 10) Choose a right statement., float a = 5/2;, float b = 5/2.0;, float c = 5.0/2;
Page 33 :
float d = 5.0/2.0;, , A) a=2.5, b=2.5, c=2.5, d=2.5, B) a=2, b=2.5, c=2.5, d=2.5, C) a=2.0, b=2.5, c=2.5, d=2.5, D) a=2.0, b=2.0, c=2.0, d=2.0, Answer [=], , C, Explanation:, In division, to get the actual real value, you should specify at least one, real number., Variable a holds only 2. But variables b,c and d contain real numbers as, either numerator or denominator is a real number., 11) If both numerator and denominator of a division operation in C, language are integers, then we get.?, A) Expected algebraic real value, B) Unexpected integer value, C) Compiler error., D) None of the above, Answer [=], , B, Explanation:, int a = 5/2 stores only 2., 12) Choose a right statement., int var = 3.5;, , A) a = 3.5, B) a = 3, C) a = 0, D) Compiler error, Answer [=], , B, Explanation:, a stores only integer value. So, 3.5 is truncated to 3., 13) Choose a right statement., int main(), {, int var = 3.5;;, printf("%f", var);
Page 34 :
return 0;, }, , A) 3.500000, B) 3, C) 3.5, D) 0.000000, Answer [=], , D, Explanation:, As the variable type is an integer, you have to use %d as a format, specifier. If you specify wrong format specifier, you will not get, expected output., 14) What is the output of the program.?, int main(), {, int a = 25%10;, printf("%d", a);, , return 0;, }, , A) 2.5, B) 2, C) 5, D) Compiler error., Answer [=], , C, Explanation:, Modulo division operator returns the reminder of division of 25 by 10., 10x2 + 5 = 25. So reminder is 5., , 15) Can you use C Modulo Division operator % with float and int?, A) Only int variables = Okay, B) Only float variables = Okay
Page 35 :
C) int or float combination = Okay, D) Numerator int variable, Denominator any variable = Okay, Answer [=], , A, Explanation:, Modulo Division operator % in C language can be used only with, integer variables or constants., 16) What is the output of the C program with Modulo Division, operator with - or Negative numbers.?, int main(), {, int a = -25%-10;, int b = -25%10;, int c = 25%-10;, , printf("%d %d %d", a, b, c);, , return 0;, }, , A) 5 -5 -5, B) 5 -5 5, C) -5 -5 5, D) 5 5 5, Answer [=], , C, Explanation:, Sign of a modulo division operation is same as the sign of Numerator., So sign of 25 is taken always., 17) What is the output of the program.?, int main(), {, float a = 45;, printf("%f", a);, , return 0;, }
Page 36 :
A) 45, B) 45.0, C) 45.000000, D) 0.000000, Answer [=], , C, Explanation:, Integer value 45 is promoted to float i.e 45.0 and printed with all 6, decimal numbers., 18) What is the priority of operators *, / and % in C language.?, A) * > / > %, B) % > * > /, C) Both % = / , * are same, D) All three operators *, / and % are same., Answer [=], , D, Explanation:, Operators Multiplication *, Division / and Modulo Division % are all, having the same Priority., 19) In C language, which Operator group has more priority between, (*, / and %) and (+, -) groups.?, A) Both groups share equal priority., B) (+, -) > (*, / and %), C) (+, -) < (*, / and %), D) None of the above., Answer [=], , C, Explanation:, + and - has same priority. *, / and % has equal priority. But (+, -) has, less priority than (*, / and %)., 20) Associativity of C Operators *, /, %, +, - and = is.?, A) Operators *, / and % have Left to Right Associativity. Operators + and - have, Left to Right Associativity. Operator = has Right to Left Associativitiy., B) Operators *, / and % have Right to Left Associativity. Operators + and - have, Left to Right Associativity. Operator = has Right to Left Associativitiy., C) Operators *, / and % have Right to Left Associativity. Operators + and - have, Right to Left Associativity. Operator = has Right to Left Associativitiy., D) Operators *, / and % have Right to Left Associativity. Operators + and - have, Right to Left Associativity. Operator = has Left to Right Associativitiy., Answer [=], , A
Page 37 :
Explanation:, Operators *, / and % have Left to Right Associativity. Operators + and, - have Left to Right Associativity. Operator = has, , SET-2, 1) What is the Priority among (*, /, %), (+, -) and (=) C, Operators.?, A) (*, /, %) > (+, -) < (=), B) (*, /, %) < (+, -) < (=), C) (*, /, %) > (+, -) > (=), D) (*, /, %) < (+, -) (+, -) == (=), Answer [=], , C, Explanation:, Assignment operator in C has the least priority., 2) What is the output of the C statement.?, int main(), {, int a=0;, a = 4 + 4/2*5 + 20;, printf("%d", a);, , return 0;, }, , A) 40, B) 4, C) 34, D) 54, Answer [=], , C, Explanation:, / and * has equal priority. But associativity is from L to R., 4 + 2*5 + 20, 4 + 10 + 20 = 34, 3) What is the output of the C Program.?
Page 38 :
int main(), {, int a=0;, a = 10 + 5 * 2 * 8 / 2 + 4;, printf("%d", a);, , return 0;, }, , A) 124, B) 54, C) 23, D) 404, Answer [=], , B, Explanation:, 10 + 10*8/2 + 4, 10 + 80/2 + 4, 10 + 40 + 4 = 54, 4) What is the output of the C Program.?, int main(), {, int a=0;, a = 4 + 5/2*10 + 5;, printf("%d", a);, , return 0;, }, , A) 29, B) 5, C) 4, D) 34, Answer [=], , A, Explanation:
Page 39 :
5/2 is 2 only because both numerator and denominator are integers. So, only int value i.e 2 is the result., 4 + 2 * 10 + 5, 4 + 20 + 5 = 29., 5) What is the output of the C Program.?, int main(), {, int a=0;, a = 10 + 2 * 12 /(3*2) + 5;, printf("%d", a);, , return 0;, }, , A) 31, B) 19, C) 11, D) 29, Answer [=], , B, Explanation:, Paranthesis changes the associativity of operators., 10 + 2 * 12 / (3*2) + 5;, 10 + 24 / (3*2) + 5;, 10+ 24/6 + 5;, 10 + 4 + 5 = 19;, 6) What is the output of the C Program.?, int main(), {, int a=0;, a = 10 + 2 * 12 / 3 * 2 + 5;, printf("%d", a);, , return 0;
Page 40 :
}, , A) 19, B) 31, C) 11, D) 25, Answer [=], , B, Explanation:, 10 + 2 * 12 / 3 * 2 + 5;, 10 + 24/3*2 + 5;, 10 + 8*2 + 5;, 10 + 16 + 5 = 31;, 7) What is the output of the C Program.?, int main(), {, float a=10.0;, a = a % 3;, printf("%f", a);, , return 0;, }, , A) 0, B) 1, C) 1.000000, D) Compiler error., Answer [=], , D, Explanation:, You can use the operator Modulus Division % with only integers., error: invalid operands to binary % (have ‘float’ and ‘int’), a = a % 3;, ^
Page 41 :
8) What is the output of the C Program.?, int main(), {, float a=10.0;, a = (int)a % 3;, printf("%f", a);, , return 0;, }, , A) 0, B) 1, C) 1.000000, D) Compiler Error., Answer [=], , C, Explanation:, Type casting from float to int is done by (int)., (int)10.000000 = 10;, 10%3 = 1. Reminder of the division of 10 by 3., %f in printf prints it as 1.000000., 9) What is the output of the C Program.?, int main(), {, int a=0;, a = 14%-5 - 2;, printf("%d", a);, , return 0;, }, , A) 0, B) -4
Page 42 :
C) -2, D) 2, Answer [=], , D, Explanation:, 14%5 = 4 ( Reminder), 14 % -5 = 4. Yes sign of the reminder is the sign of Numerator., 4- 2 = 2;, 10) What is the output of the C Program.?, int main(), {, int a= 3 + 5/2;, printf("%d", a);, , return 0;, }, , A) 3, B) 2, C) 5, D) Can not assign an expression to variable at the time of declaration., Answer [=], , C, Explanation:, Assignment Operator = in C language has the least priority. So the right, hand side expression is evaluated first and then assigned to the left, side variable., a = 3 + 5/2;, a = 3 + 2;, a=, , BITWISE OPERATORS, 1) What are Nibble, Word and Byte in computer language.?
Page 43 :
A) Byte = 8 bits, Word= 4 Bytes, Nibble= 8 Bytes, B) Byte = 8 bits, Word=2 Bytes, Nibble=4 Bytes, C) Byte = 8 bits, Word=12 bits, Nibble=32 Bits, D) Byte = 8 bits, Word=24 bits, Nibble=40 Bits, Answer [=], , B, 2) Choose correct representation of Decimal number in Binary., A), 0, , 0000, , 1, , 0001, , 2, , 0010, , 3, , 0011, , 4, , 0100, , B), 5, , 0101, , 6, , 0110, , 7, , 0111, , 8, , 1000, , 9, , 1001, , C), 10, , 1010, , A, , 11, , 1011, , B, , 12, , 1100, , C, , 13, , 1101, , D, , 14, , 1110, , E, , 15, , 1111, , F, , D) All the above, Answer [=], , D, Explanation:, A B C D E and F are HEX or Hexadecimal notation., printf("%X", 10);//A, printf("%x", 10);//a
Page 44 :
3) What is the operator used to make 1's One's compliment.?, A) & Bitwise AND Operator, B) | Bitwise OR operator, C) ~ Bitwise Negate Operator, D) ^ Bitwise Exclusive OR, Answer [=], , C, Explanation:, One's complement is created by Negate Operator ~., 00010110 is changed to 11101001 after applying ~ operator., , 4) What is the result of 0110 & 1100.?, A) 1000, B) 0100, C) 0001, D) 1010, Answer [=], , B, Explanation:, Bitwise & operator gives 1 if both operands are 1. 1&1 = 1., 0&0=0, 0&1=0, 1&0=0, 1&1=1, , 5) What is the output of Bitwise OR operation | on (0110 | 1100).?, A) 1110, B) 1100, C) 1000, D) 1010, Answer [=], , A, Explanation:, Bitwise OR operation compares both operands. If at least one operand, is 1 output is 1., 0|0=0, 0|1=1, 1|0=1
Page 45 :
1|1=1, , 6) What is the output of Exclusive OR ^ operator on 0110^1000.?, A) 1000, B) 1110, C) 0011, D) 0001, Answer [=], , B, Explanation:, Exclusive OR ^ compares both operands. If both operands are different,, output is 1., 0^0=1, 0^1=1, 1^0=1, 1^1=0, , 7) What is the output of Left Shift Operator << on (00011000<<2).?, A) 01100000, B) 11000000, C) 00000110, D) 00000011, Answer [=], , A, Explanation:, Left Shift Operator << shifts bits on the left side and fills Zeroes on the, Right end., , 8) What is the result of Right Shift Operator >> on, (00110000>>2).?, A) 11000000, B) 00001100, C) 01100000, D) 11001111, Answer [=], , B, Explanation:
Page 46 :
Right Shift Operator shift bits on the right side and fills Zeroes on the, left side., 9) Choose correct statement about Left Shift Operator << .?, A) Left shift operator shifts individual bits on the left side, B) When shifting left side, overflow bits are ignored., C) Zeroes are filled on the right side, D) All the above, Answer [=], , D, 10) Choose a correct statement about Right Shift Operator >> .?, A) Right shift operator shift individual bits on to the right side., B) When shifting bits right side, overflow bits on the right are ignored or, truncated., C) Zeroes are filled on the left side., D) All the above, Answer [=], , D, 11) What is a Single Operand Operator below.?, A) &, B) |, C) ^, D) ~, Answer [=], , D, Explanation:, TILDE or Negation works on single Operand. ~1100=0011., 12) What is the Bitwise operator used to set a particular bit, value to 1.?, A) & AND, B) | OR, C) ^ Exclusive OR, D) ~ Operator, Answer [=], , B, Explanation:, To set a 3 bit to 0 from right in 0000001, OR with 00000100. Output is, 00000101., 13) What is the Bitwise operator used set a particular bit to Zero, 0.?, A) & Operator
Page 47 :
B) | OR operator, C) ^ Exclusive Operator, D) ~ TILDE Operator, Answer [=], , A, Explanation:, To set a 4th bit to 0, AND with 11110111., 00111000 & 11110111 =00110000;, , 14) Which is Bit Toggling operator below.?, A) & AND operator, B) | OR operator, C) ^ Exclusive Operator, D) ~ TILDE operator, Answer [=], , D, , 15) Which is the format specifier used to prefix 0x and print a, number in hexadecimal notation.?, A) %x, B) %0x, C) %#x, D) %hx, Answer [=], , C, Explanation:, printf("%#x", 10);, //output: 0xa, , 16) Left Shift operation is equivalent to.?, A) Division by 2, B) Multiplying by 2, C) Adding 2, D) Subtracting 2, Answer [=], , B, Explanation:, Yes. (0001)<<1 = 0010. 1 x 2= 2 i.e 10 in binary.
Page 48 :
17) Right Shift operation >> is equivalent to .?, A) Multiplying by 2, B) Division by 2, C) Adding 2, D) Subtracting 2, Answer [=], , B, Explanation:, 0100>>1 = 0010. So 4 / 2 = 2 = 10 in binary., 18) What is the minimum and maximum values in Octal Number, System.?, A) 1 to 8, B) 0 to 7, C) 2 to 9, D) None of the above, Answer [=], , B, Explanation:, 10 in decimal = 12 in octal = 1100 in Binary., 19) What number system is not understood by C language compiler, directly.?, A) Decimal, B) Octal, C) Binary, D) Hex Decimal, Answer [=], , C, Explanation:, Yes. C language can not understand Binary language directly. Because C, language is a High Level Language., 20) Choose a correct statement about C Bitwise operators.?, A) 0^number = number, B) 1 | number = number, C) 0 & number = 0, D) All the above, Answer [=], , D
Page 49 :
CONDITIONAL STATEMENTS OR OPERATORS, SET-1, 1) Choose a C Conditional Operator from the list., A) ?:, B) :?, C) :<, D) <:, Answer [=], , A, Explanation:, ?: = Question Mark Colon is also called C Ternary Operator., , 2) What is the other name for C Language ?: Question Mark Colon, Operator.?, A) Comparison Operator, B) If-Else Operator, C) Binary Operator, D) Ternary Operator, Answer [=], , D, , 3) Choose a syntax for C Ternary Operator from the list., A) condition ? expression1 : expression2, B) condition : expression1 ? expression2, C) condition ? expression1 < expression2, D) condition < expression1 ? expression2, Answer [=], , A, Explanation:, If the condition is true, expression 1 is evaluated. If the condition is false, expression 2 is evaluated., , 4) What is the output of the C statement.?, int main(), {, int a=0;, a = 5<2 ? 4 : 3;, printf("%d",a);, , return 0;, }, A) 4, B) 3, C) 5, D) 2, Answer [=]
Page 50 :
B, Explanation:, 5<2 is false. So 3 will be picked and assigned to the variable a., , 5) What is the output of C Program.?, int main(), {, int a=0;, a = printf("4");, printf("%d",a);, , return 0;, }, A) 04, B) compiler error, C) 40, D) 41, Answer [=], , D, Explanation:, a = printf("4");, First printf prints 4. printf() returns 1. Now the variable a=1; So 1 is printed next., , 6) What is the output of the C Program.?, int main(), {, int a=0;, a = 5>2 ? printf("4"): 3;, printf("%d",a);, , return 0;, }, A) compiler error, B) 14, C) 41, D) 0, Answer [=], , C, Explanation:, 5>2 is true. So expression1 i.e printf("4) is executed printing 4. Function printf() returns 1. So a value is 1., , 7) What is the output of the C Program.?
Page 51 :
int main(), {, int a=0;, a = (5>2) ? : 8;, printf("%d",a);, , return 0;, }, A) 0, B) 1, C) 8, D) compiler error, Answer [=], , B, Explanation:, expression1 = empty, expression2 = 8, If no expression is specified, it will be treated as 1., , 8) What is the output of C Program.?, int main(), {, int a=0, b;, a = (5>2) ? b=6: b=8;, printf("%d %d",a, b);, , return 0;, }, A) 6 6, B) 0 6, C) 0 8, D) compiler error, Answer [=], , D, Explanation:, Compiler error. a = (5>2) ? b=6: b=8; should be written as a = (5>2) ? b=6: (b=8);, main.c: In function ‘main’:
Page 52 :
main.c:14:23: error: lvalue required as left operand of assignment, a = (5>2) ? b=6: b=8;, ^, , 9) Choose a correct statement regarding C Comparison Operators., A) (x == y) Is x really equal to y. (x != y) Is x not equal to y., B) (x < y) Is x less than y (x > y) Is x greater than y, C) (x <= y) Is x less than or equal to y. (x >= y) Is x greater than or equal to y, D) All the above, Answer [=], , D, , 10) Choose a statement to use C If Else statement., A) else if is compulsory to use with if statement., B) else is compulsory to use with if statement., C) else or else if is optional with if statement., D) None of the above, Answer [=], , C, , 11) Choose a correct C Statement using IF Conditional Statement., A), if( condition ), {, //statements;, }, B), if( condition ), {, //statements;, }, else, {, //statements;, }, C), if( condition1 ), {, //statements;, }
Page 53 :
else if( condition2), {, //statements;, }, else, {, //statements;, }, D) All the above., Answer [=], , D, , 12) What is the output of the C Program.?, int main(), {, if( 4 > 5 ), {, printf("Hurray..\n");, }, printf("Yes");, , return 0;, }, A) Yes, B) Hurray.. Yes, C) Hurray..Yes, D) Compiler error, Answer [=], , A, Explanation:, if condition fails. So control will not enter Hurray printf statement., , 13) What is the output of the C Program.?, int main(), {, if( 4 > 5 ), printf("Hurray..\n");, printf("Yes");
Page 54 :
return 0;, }, A) Yes, B) Hurray.. Yes, C) Hurray..Yes, D) No Output, Answer [=], , A, Explanation:, To include more than one statement inside If block, use { } braces. Otherwise, only first statement after if, block is included. IF condition fails with false. So second if which is outside of If is executed., , 14) What is the output of the C Program.?, int main(), {, if( 4 < 5 ), printf("Hurray..\n");, printf("Yes");, else, printf("England"), , return 0;, }, A) Hurray..Yes, B) Hurray.. Yes, C) Compiler error, D) None of the above, Answer [=], , C, Explanation:, If block includes only Single Hurray printf statement without curly braces { }. So second Yes printf, statement is not part of IF block. Else should immediately follow IF block. Otherwise, compiler throws, errors. To compile well, use { } braces for two printf statements or remove second printf after IF., , 15) What is the output of the C Program.?, int main(), {, if( 10 < 9 )
Page 55 :
printf("Hurray..\n");, else if(4 > 2), printf("England");, , return 0;, }, A) England, B) Hurray.., C) Compiler error for missing else, D) None of the above, Answer [=], , A, Explanation:, You can omit ELSE comfortably. Compiler will not complain above ELSE after IF or ELSE IF., , 16) What is the output of C Program.?, int main(), {, if( 10 > 9 ), printf("Singapore\n");, else if(4%2 == 0), printf("England\n");, printf("Poland");, return 0;, }, A) Singapore, B) Singapore Poland, C) Singapore England Poland, D) England Poland, Answer [=], , B, Explanation:, Observe that Poland printf is not under ELSE IF as there are two statements without curly braces { }. IF, condition is TRUE. So, ELSE IF will not be seen at all even though 4%2 == 0 is true., , 17) What is the output of the C Program.?, int main(), {, if(-5), {
Page 56 :
printf("Germany\n");, }, if(5), {, printf("Texas\n");, }, printf("ZING");, , return 0;, }, A) ZING, B) Texas ZING, C) Germany Texas ZING, D) Compiler error as a number can not be put as condition inside IF., Answer [=], , C, Explanation:, You can use any number inside IF as a condition., Positive Number or Negative Number evaluates to true., Number 0 Zero evaluates to false., , 18) What is the output of the C Program.?, int main(), {, if(10.0), {, printf("Texas\n");, }, printf("ZING");, , return 0;, }, A) ZING, B) Texas ZING, C) Compiler error., D) None of the above., Answer [=], , B, Explanation:
Page 57 :
You can use either Integer or Real numbers. 0 or 0.0 evaluates to false condition., , 19) What is the output of C Program.?, int main(), {, if("abc"), {, printf("India\n");, }, if('c'), {, printf("Honey\n");, }, printf("ZING");, , return 0;, }, A) ZING, B) Honey ZING, C) India ZING, D) India Honey ZING, Answer [=], , D, Explanation:, "abc" is string and it returns an Integer Address Number. 'c' returns an ASCII number which is also a, number. Any Non-Zero number gives TRUE condition., , 20) What is the output of C Program.?, int main(), {, if(TRUE), {, printf("India\n");, }, if(true), {, printf("Honey\n");, }, printf("ZING");
Page 58 :
return 0;, }, A) India ZING, B) Honey ZING, C) India Honey ZING, D) Compiler error, Answer [=], , D, Explanation:, There are no keywords (true) or (TRUE). These available in Java, JavaScript and other languages., , SET-2, 1) What is the output of C Program with Switch Statement.?, int main(), {, , int a=5;, , switch(a), {, case 0: printf("0 ");, case 3: printf("3 ");, case 5: printf("5 ");, default: printf("RABBIT ");, }, , a=10;, switch(a), {, case 0: printf("0 ");, case 3: printf("3 ");, case 5: printf("5 ");, default: printf("RABBIT "); break;, }
Page 59 :
return 0;, }, A) 5 RABBIT, B) 0 3 5 RABBIT 0 3 5 RABBIT, C) 0 3 5 RABBIT RABBIT, D) 3 5 RABBIT RABBIT, Answer [=], , D, Explanation:, Absence of break; after case statement causes control to go to next case automatically. So after matching 3, with a==3, program prints 3 and control falls down the ladder without checking case again printing, everything below it. So Switch checks only once and falls down., , 2) What is the output of C Program with switch statement.?, int main(), {, int a=3;, , switch(a), {, case 2: printf("ZERO "); break;, , case default: printf("RABBIT ");, }, , }, A) RABBIT, B) ZERO RABBIT, C) No output, D) Compiler error, Answer [=], , D, Explanation:, Notice that it is "default" not "case default"., , 3) What is the output of C Program with switch statement or, block.?, int main(), {, int a=3;
Page 60 :
switch(a), {, , }, , printf("MySwitch");, }, A) MySwitch, B) No Output, C) Compiler Error, D) None of the above, Answer [=], , A, Explanation:, Yes. It is okay to omit CASE: statements inside SWITCH construct or block., , 4) What is the output of C Program with switch statement or, block.?, int main(), {, int a;, , switch(a), {, printf("APACHE ");, }, , printf("HEROHONDA");, }, A) APACHE HEROHONDA, B) HEROHONDA, C) No Output, D) Compiler error, Answer [=], , B, Explanation:, Notice the missing CASE or DEFAULT statements. Still compiler accepts. But without CASE statement, nothing will be printed inside of SWITCH., switch(a)
Page 61 :
{, printf("APACHE ");, }, , 5) What is the output of C program with switch statement or, block.?, int main(), {, int a;, , switch(a);, {, printf("DEER ");, }, , printf("LION");, }, A) LION, B) DEER LION, C) Compiler error, D) None of the above, Answer [=], , B, Explanation:, Notice a semicolon at the end of switch(a);. So, printf DEER is out of SWITCH., switch(a), {, ;, }, , {, printf("DEER ");, }, , 6) What is the output of C Program with switch statement or, block.?, int main()
Page 62 :
{, static int a=5;, , switch(a), {, case 0: printf("ZERO ");break;, case 5: printf("FIVE ");break;, case 10: printf("DEER ");, }, , printf("LION");, }, A) ZERO FIVE DEER LION, B) FIVE DEER LION, C) FIVE LION, D) Compiler error, Answer [=], , C, Explanation:, After matching 5, FIVE will be printed. BREAK causes control to exit SWITCH immediately. Also, using, a STATIC variable is also allowed., , 7) What is the output of C program with switch statement or, block.?, int main(), {, char code='K';, , switch(code), {, case 'A': printf("ANT ");break;, case 'K': printf("KING "); break;, default: printf("NOKING");, }, , printf("PALACE");, }
Page 63 :
A) KING PALACE, B) KING NOTHING PALACE, C) ANT KING PALACE, D) Compiler error for using Non Integers as CASE constants., Answer [=], , A, Explanation:, Any character is replaced by ASCII code or number by the compiler. So it is allowed to use, CHARACTER constants for CASE constants., , 8) What is the output of C Program with switch statement or, block.?, int main(), {, char code='K';, , switch(code), {, case "A": printf("ANT ");break;, case "K": printf("KING "); break;, default: printf("NOKING");, }, , printf("PALACE");, }, A) ANT KING PALACE, B) KING PALACE, C) PALACE, D) Compiler error, Answer [=], , D, Explanation:, You can not use STRING constants with DOUBLE QUOTES as CASE constants. Only expressions, leading or constants leading to Integers are allowed., , 9) What is the output of C Program with switch statement or, block.?, int main(), {, char code='A';
Page 64 :
switch(code), {, case 64+1: printf("ANT ");break;, case 8*8+4: printf("KING "); break;, default: printf("NOKING");, }, , printf("PALACE");, }, A) ANT KING PALACE, B) KING PALACE, C) ANT PALACE, D) Compiler error for using expressions, Answer [=], , C, Explanation:, ASCII value of 'A' is 65. So (64+1) matches A. Also expression leading to Integers can be used as CASE, Constants., , 10) What is the output of C Program with switch statement or, block.?, int main(), {, char code=64;, , switch(code), {, case 64: printf("SHIP ");break;, case 8*8: printf("BOAT "); break;, default: printf("PETROL");, }, , printf("CHILLY");, }, A) SHIP CHILLY, B) BOAT CHILLY, C) BOAT PETROL CHILLY
Page 65 :
D) Compiler error, Answer [=], , D, Explanation:, You can not use DUPLICATE SWITCH Case Constants. 64 == (8*)., , 11) What is the output of C Program with switch statement or, block.?, int main(), {, int k=64;, , switch(k), {, case k<64: printf("SHIP ");break;, case k>=64: printf("BOAT "); break;, default: printf("PETROL");, }, , printf("CHILLY");, }, A) BOAT CHILLY, B) BOAT PETROL CHILLY, C) SHIP BOAT CHILLY, D) Compiler error, Answer [=], , D, Explanation:, You can not use comparison operations with CASE statements in SWITCH., , 12) What is the output of C Program with switch statement or, block.?, int main(), {, int k=8;, , switch(k), {, case 1==8: printf("ROSE ");break;, case 1 && 2: printf("JASMINE "); break;
Page 66 :
default: printf("FLOWER ");, }, , printf("GARDEN");, }, A) ROSE GARGEN, B) JASMINE GARDEN, C) FLOWER GARDEN, D) Compiler error, Answer [=], , C, Explanation:, (1==8) is false i.e 0. (1&&2) is true AND true i.e true i.e 1. So case allowed first ZERO 0 and then ONE 1., All integer constants are allowed for SWITCH Case Constants., , 13) What is the output of C Program with switch statement or, block.?, int main(), {, int k=25;, , switch(k), {, case 24: printf("ROSE ");break;, case 25: printf("JASMINE "); continue;, default: printf("FLOWER ");, }, , printf("GARDEN");, }, A) JASMINE GARDEN, B) JASMINE FLOWER GARDEN, C) FLOWER GARDEN, D) Compiler error, Answer [=], , D, Explanation:, You can not use CONTINUE; statement as SWITCH is not a LOOP like for, while and do while., , 14) What is the output of C Program with switch statement or, block.?
Page 67 :
int main(), {, switch(24.5), {, case 24.5: printf("SILVER ");break;, case 25.0: printf("GOLD "); break;, default: printf("TIN ");, }, , printf("COPPER");, }, A) SILVER COPPER, B) TIN COPPER, C) COPPER, D) Compiler error, Answer [=], , D, Explanation:, You can not use float, double or Strings inside Switch or Switch CASE., , 15) Choose a correct statement about a C Switch Construct., A) default case is optional inside switch., B) break; causes the control to exit the switch immediately and avoid fall down to other CASE statements., C) You can not use duplicate CASE Constants inside a Switch construct., D) All the above., Answer [=], , D, , SET-3, 1) What is the output of C Program.?, int main(), {, int x=1;, float y = 1.0;, if(x == y)
Page 68 :
{, printf("Polo\n");, }, if( 1 == 1.0), {, printf("Golf\n");, }, , if( 1.0 == 1.0f ), {, printf("Boxing\n");, }, return 0;, }, A) No Output, B) Boxing, C) Golf Boxing, D) Polo Golf Boxing, Answer [=], , D, Explanation:, Integer is promoted to float or double automatically before comparison. So all are equal., 1 == 1.0 == 1.0f, , 2) What is the output of C Program.?, int main(), {, int a=9;, if(a=8), {, printf("Kangaroo\n");, }, printf("Eggs\n");, , return 0;, }, A) No output
Page 69 :
B) Eggs, C) Kangaroo Eggs, D) Compiler error, Answer [=], , C, Explanation:, a=8 is an assignment not comparison. IF( Non Zero) is always TRUE., , 3) What is the output of C Program.?, int main(), {, int a=9;, if(a==5);, {, printf("Kangaroo\n");, }, printf("Eggs\n");, , return 0;, }, A) Eggs, B) Kangaroo Eggs, C) No output, D) Compiler error, Answer [=], , B, Explanation:, Notice a Semicolon at the end of IF(a==5);. So IF block ends without any statements. Also, { } is not part, of IF now. So it is executed without checking for any condition., , 4) What is the output of C Program.?, int main(), {, int a=9;, if(a==9);, {, printf("Ostrich\n");, }, elseif(a==8), {, printf("Eggs\n");
Page 70 :
}, , printf("White");, , return 0;, }, A) White, B) Ostrich White, C) No Ouput, D) Compiler error, Answer [=], , D, Explanation:, Notice IFELSE statement. There should be one SPACE between IF and ELSE., , 5) What is the output of C Program.?, int main(), {, int a=9;, if(a==9), {, printf("Ostrich\n");, }, else;, {, printf("Eggs\n");, }, , printf("White");, , return 0;, }, A) White, B) Ostrich White, C) Ostrich Eggs White, D) Compiler Error, Answer [=], , C, Explanation:
Page 71 :
Notice a Semicolon (;) at the end of ELSE. So ELSE is terminated immediately. Eggs Printf block is not, part of ELSE and is always called., , 6) What is the output of C Program.?, int main(), {, int a=9, b=5, c=8;, a=b=c=10;, if(a==9), {, printf("Ostrich\n");, }, else, {, printf("Eggs\n");, }, , printf("White");, , return 0;, }, A) Ostrich Eggs White, B) Ostrich White, C) Eggs White, D) Compiler error as you can not assign to more than two variables at once., Answer [=], , C, , 7) What is the output of C Program.?, int main(), {, int a=9, b=5, c=8;, , if(!(a==9)), {, printf("Bear\n");, }, else
Page 72 :
{, printf("Elephant\n");, }, , printf("Fox");, , return 0;, }, A) Bear Fox, B) Elephant Fox, C) Fox, D) Compiler error, Answer [=], , B, Explanation:, Logical Not Operator ( ! ) changes true to false and false to true. So IF(false) is not executed., , 8) What is the Priority of C Logical Operators.? NOT (!), AND (&&), and OR (||), A) NOT (!) > AND (&&) > OR (||), B) NOT (!) > AND (&&) = OR (||), C) AND (&&) > OR (||) > NOT (!), D) AND (&&) = OR (||) > NOT (!), Answer [=], , A, Explanation:, Logical NOT Operator in C has the highest priority., , 9) What is the output of C Program.?, int main(), {, int a=9, b;, , b = (a==9) ? (printf("CAT\n");printf("DOG\n")) : (printf("FOX"));, , return 0;, }, A) CAT DOG, B) FOX
Page 73 :
C) CAT DOG FOX, D) Compiler error, Answer [=], , D, Explanation:, You can not put more than 1 statement inside expression1 or expression2 inside Ternary Operator., (Condition)?(expression1):(expression2), , 10) What is the output of C Program.?, int main(), {, int a=9, b=6;, if(a==9 && b==6), {, printf("Hockey");, }, else, {, printf("Cricket");, }, , return 0;, }, A) Cricket Football, B) Hockey Football, C) Football, D) Compiler error, Answer [=], , B, Explanation:, == operator has more priority than &&. Logical && AND operator returns true only if both expressions, are true., , 11) What is the output of C Program.?, int main(), {, int a=9, b=6;, if(a!=9 || b==6), {
Page 74 :
printf("Hockey\n");, }, else, {, printf("Cricket\n");, }, , printf("Football");, , return 0;, }, A) Cricket Football, B) Hockey Football, C) Football, D) Compiler error, Answer [=], , B, Explanation:, Logical OR || operator returns true if any one expression is true., , 12) Choose a correct C Operator Priority.? Items in one group ( ), has same priority., A) ( ! ) < (*, /, %) < (+, -) < ( <, <=, >, >=) < (==, !=) < (&&) < (||) < (=), B) (( ! ) , (*, /, %) , (+, -)) < ( <, <=, >, >=) < (==, !=) < (&&) < (||) < (=), C) ( ! ) > (*, /, %) > (+, -) > ( <, <=, >, >=) > (==, !=) > (&&) > (||) > (=), D) (( ! ) , (*, /, %) , (+, -)) > ( <, <=, >, >=) > (==, !=) > (&&) > (||) > (=), Answer [=], , C, Explanation:, ( ! Logical NOT ) > (*, /, % Arithmetic) > (+, - Arithmetic) > ( <, <=, >, >= Relational) > (==, != Relational), > (&& Logical AND) > (|| Logical OR) > (= Assignment)., , 13) What is the output of C Program.?, int main(), {, int a=5, b=8;, , if( a==5 && (b=9) ), {, printf("Gorilla Glass=");, }
Page 75 :
printf("%d %d", a, b);, , return 0;, }, A) 5 8, B) 5 9, C) Gorilla Glass=5 8, D) Gorilla Glass=5 9, Answer [=], , D, Explanation:, In IF( a==5 && (b=9) ), && Operator checks both expressions for true or Non Zero value. So after, checking a==5, b=9 is checked. Here b==9 is checking, but b=9 is assignment. Any NON-Zero value is true, only. So b=9 now., , 14) What is the output of C Program.?, int main(), {, int a=5, b=8;, , if( a==5 || (b=9) ), {, printf("Gorilla Glass=");, }, printf("%d %d", a, b);, , return 0;, }, A) 5 8, B) 5 9, C) Gorilla Glass=5 8, D) Gorilla Glass=5 9, Answer [=], , C, Explanation:, Logical OR || checks wants only one TRUE condition. First expression (a==5) or even (a=5) is true. So, second expression (b=9) is not evaluated and assignment not done. So b=8 only., , 15) Choose a correct C Statement.
Page 76 :
A) Nesting of ? : operator is possible., B), int main(), {, int a=5, b=8;, , if( a>=5 || (b=9) ), {, printf("Gorilla Glass");, }, , return 0;, }, //OUTPUT: Gorilla Glass, C), int main(), {, int a=5, b=8;, , if( a >= 5 && b <= 9 ), {, printf("Gorilla Glass");, }, , return 0;, }, //OUTPUT: Gorilla Glass, D) All the above, Answer [=], , D, , LOOPS SET-1, 1) Choose a right C Statement., A) Loops or Repetition block executes a group of statements repeatedly.
Page 77 :
B) Loop is usually executed as long as a condition is met., C) Loops usually take advantage of Loop Counter, D) All the above., Answer [=], , D, , 2) Loops in C Language are implemented using.?, A) While Block, B) For Block, C) Do While Block, D) All the above, Answer [=], , D, , 3) Which loop is faster in C Language, for, while or Do While.?, A) for, B) while, C) do while, D) All work at same speed, Answer [=], , D, , 4) Choose correct C while loop syntax., A), while(condition), {, //statements, }, B), {, //statements, }while(condition), C), while(condition);, {, //statements, }, D), while(), {, if(condition), {
Page 78 :
//statements, }, }, Answer [=], , A, , 5) Choose a correct C for loop syntax., A), for(initalization; condition; incrementoperation), {, //statements, }, B), for(declaration; condition; incrementoperation), {, //statements, }, C), for(declaration; incrementoperation; condition), {, //statements, }, D), for(initalization; condition; incrementoperation;), {, //statements, }, Answer [=], , A, Explanation:, increment or decrement operation at third place., , 6) Choose a correct C do while syntax., A), dowhile(condition), {
Page 79 :
//statements, }, B), do while(condition), {, //statements, }, C), do, {, //statements, , }while(condition), D), do, {, //statements, , }while(condition);, Answer [=], , D, Explanation:, Semicolon after while(condition) is a must., , 7) What is the output of C Program.?, int main(), {, while(true), {, printf("RABBIT");, break;, }, , return 0;
Page 80 :
}, A) RABBIT, B) RABBIT is printed unlimited number of times., C) No output, D) Compiler error., Answer [=], , D, Explanation:, while(TRUE) or while(true) does not work. true is not a keyword., , 8) What is the output of C Program.?, int main(), {, int a=5;, , while(a==5), {, printf("RABBIT");, break;, }, , return 0;, }, A) RABBIT is printed unlimited number of times, B) RABBIT, C) Compiler error, D) None of the above., Answer [=], , B, Explanation:, If there is no BREAK statement, while loop runs continuously util the computer hangs. BREAK causes, the loop to break once and the statement below the while if any will be executed., , 9) What is the output of C Program.?, int main(), {, int a=5;
Page 81 :
while(a=123), {, printf("RABBIT\n");, break;, }, printf("GREEN");, , return 0;, }, A) GREEN, B) RABBIT GREEN, C) RABBIT is printed unlimited number of times., D) Compiler error., Answer [=], , B, Explanation:, while(a=123) = while(123) = while(Non Zero Number). So while is executed. BREAK breaks the loop, immediately. Without break statement, while loop runs infinite number of times., , 10) What is the output of C Program.?, int main(), {, int a=5;, , while(a >= 3);, {, printf("RABBIT\n");, break;, }, printf("GREEN");, , return 0;, }, A) GREEN, B) RABBIT GREEN, C) RABBIT is printed infinite times, D) None of the above, Answer [=], , D
Page 82 :
Explanation:, Notice a semicon(;) after while condition. It makes the printf and break statement blocks isolate., while(a >= 3), {, ;//infinite loop, }, {, printf("RABBIT\n");, break;, }, , 11) What is the output of C Program.?, int main(), {, int a=25;, , while(a <= 27), {, printf("%d ", a);, a++;, }, , return 0;, }, A) 25 25 25, B) 25 26 27, C) 27 27 27, D) Compiler error, Answer [=], , B, Explanation:, a++ is equivalent to a=a+1;, a is incremented each time., , 12) What is the output of C Program.?, int main(), {, int a=32;
Page 83 :
do, {, printf("%d ", a);, a++;, }while(a <= 30);, , return 0;, }, A) 32, B) 33, C) 30, D) No Output, Answer [=], , A, Explanation:, do { } block is executed even before checking while(condition) at least once. This prints 32. To loop for the, second time, while (32 <= 30) fails. So, loop is quit., , 13) What is the output of C Program.?, int main(), {, int a=32;, , do, {, printf("%d ", a);, a++;, if(a > 35), break;, }while(1);, , return 0;, }, A) No Output, B) 32 33 34, C) 32 33 34 35, D) Compiler error, Answer [=]
Page 84 :
C, Explanation:, while(1) is infinite loop. So we kept if(condition) to break the loop. a++ is equivalent to a=a+1;, , 14) Choose a correct C Statement., A) a++ is (a=a+1) POST INCREMENT Operator, B) a-- is (a=a-1) POST DECREMENT Opeartor --a is (a=a-1) PRE DECREMENT Opeator, C) ++a is (a=a+1) PRE INCRMENT Operator, D) All the above., Answer [=], , D, , 15) Choose correct Syntax for C Arithmetic Compound Assignment, Operators., A) a+=b is (a= a+ b) a-=b is (a= a-b), B) a*=b is (a=a*b) a/=b is (a = a/b), C) a%=b is (a=a%b), D) All the above., Answer [=], , D, , 16) What is the output of C Program.?, int main(), {, int k, j;, , for(k=1, j=10; k <= 5; k++), {, printf("%d ", (k+j));, }, , return 0;, }, A) compiler error, B) 10 10 10 10 10, C) 11 12 13 14 15, D) None of the above, Answer [=], , C, Explanation:, You can initialize any number of variables inside for loop., , 17) What is the output of C Program.?
Page 85 :
int main(), {, int k;, , for(k=1; k <= 5; k++);, {, printf("%d ", k);, }, , return 0;, }, A) 1 2 3 4 5, B) 1 2 3 4, C) 6, D) 5, Answer [=], , C, Explanation:, Semicolon at the end of for(); isolates the below print() block. After for loop is over, k value is 6., for(k=1; k <= 5; k++), {, ;, }, {, printf("%d ", k);, }, , 18) What is the output of C Program.?, int main(), {, int k;, , for(;;), {, printf("TESTING\n");, break;
Page 86 :
}, , return 0;, }, A) No Output, B) TESTING, C) Compiler error, D) None of the above, Answer [=], , B, Explanation:, for(;;) loop need not contain any initialization, condition and incre/decrement sections. All are optional., BREAK breaks the FOR Loop., , 19) What is the output of C Program.?, int main(), {, int k;, , for(printf("FLOWER "); printf("YELLOW "); printf("FRUITS ")), {, break;, }, , return 0;, }, A) Compiler error, B) FLOWER FRUITS, C) FLOWER YELLOW, D) FLOWER YELLOW FRUITS, Answer [=], , C, Explanation:, for(anything; anything; anything) is Ok. printf("YELLOW") prints YELLOW and returns 1 as result. So, for loop runs forever. Actually break is saving us from quitting the for loop. Only after checking condition, and executing the loop statements, third section is executed. break causes the loop to quit without, incre/decrement section., , 20) What is the way to suddenly come out of or Quit any Loop in C, Language.?, A) continue; statement, B) break; statement, C) leave; statement
Page 87 :
D) quit; statement, Answer [=], , B, Explanation:, eg., while(condition), {, break;, }, , SET-2, 1) Choose facts about continue; statement is C Language., A) continue; is used to take the execution control to next iteration or sequence, B) continue; statement causes the statements below it to skip for execution, C) continue; is usually accompanied by IF statement., D) All the above., Answer [=], , D, , 2) What is the output of C Program.?, int main(), {, int a=14;, , while(a<20), {, ++a;, if(a>=16 && a<=18), {, continue;, }, printf("%d ", a);, , }, , return 0;, }, A) 15 16 17 18 19
Page 88 :
B) 15 18 19, C) 15 16 20, D) 15 19 20, Answer [=], , D, Explanation:, Between 16 - 18, continue statement skips all other statements below it. So a will not be printed during, that time., 15 printed, 16 not printed, 17 not printed, 18 not printed, 19 printed, 20 printed, , 3) Choose a correct statement about C break; statement.?, A) break; statement can be used inside switch block, B) break; statement can be used with loops like for, while and do while., C) break; statement causes only the same or inner loop where break; is present to quit suddenly., D) All the above., Answer [=], , D, , 4) Choose a correct statement about C language break; statement., A) A single break; statement can force execution control to come out of only one loop., B) A single break; statement can force execution control to come out of a maximum of two nested loops., C) A single break; statement can force execution control to come out of a maximum of three nested loops., D) None of the above., Answer [=], , A, , 5) Choose a correct C Statement regarding for loop., for(; ;);, A) for loop works exactly first time, B) for loop works infinite number of times, C) Compiler error, D) None of the above, Answer [=], , B, Explanation:, We are not specifying condition to exit the loop. Eg. for(a=0;a<10;a++), , 6) What is the output of C Program.?, int main(), {, int a=10, b, c;, b=a++;
Page 89 :
c=++a;, printf("%d %d %d", a, b, c);, , return 0;, }, A) 10 11 12, B) 12 10 12, C) 12 11 12, D) 12 12 12, Answer [=], , B, Explanation:, a++ first assigns 10 to b. Next a is incremented separately. ++a increments from 11 to 12. Final ++a value, is assigned to the left side variable C., , 7) What is the output of C Program.?, int main(), {, int a=0, b=0;, while(++a < 4), printf("%d ", a);, , while(b++ < 4), printf("%d ", b);, , return 0;, }, A) 0 1 2 3 1 2 3 4, B) 1 2 3 1 2 3 4, C) 1 2 3 4 1 2 3 4, D) 1 2 3 4 0 1 2 3, Answer [=], , B, Explanation:, (++a < 4) first increments and compares afterwards. (b++ < 4) first compares and increments afterwards., , 8) What is the output of C Program.?, int main()
Page 90 :
{, int a=10,b=20;, , if(a==9 AND b==20), {, printf("Hurray..");, }, , if(a==10 OR b==21), {, printf("Theatre");, }, , return 0;, }, A) Theatre, B) Hurray Theatre, C) No output, D) Compiler error, Answer [=], , D, Explanation:, There are no keywords like AND / OR in C language. Logical OR is represented with two Pipes ||. Logical, AND is represented with two Ampersands &&., , 9) What are C ASCII character ranges.?, A) A to Z = 65 to 91, B) a to z = 97 to 122, C) 0 to 9 = 48 to 57, D) All the above, Answer [=], , D, Explanation:, All remaining characters are special characters or symbols in C Language. 0 to 47, 58 to 64, 91 to 96, 123, to 127., , 10) Expand or Abbreviate ASCII with regard to C Language., A) Australian Standard Code for Information Interchange, B) American Standard Code for Information Interchange, C) American Symbolic Code for Information Interchange, D) Australian Symbolic Code for Information Interchange, Answer [=], , B, Explanation:
Page 91 :
There were only 128 Characters with 7 Bits in Original ASCII specification. Present character standard in, all modern programming languages is UNICODE which covers all languages, Emojis and other special, symbols all over the world., , FUNCTION SET-1, 1) Choose correct statement about Functions in C Language., A) A Function is a group of c statements which can be reused any number of, times., B) Every Function has a return type., C) Every Function may no may not return a value., D) All the above., Answer [=], , D, 2) Choose a correct statement about C Language Functions., A) A function name can not be same as a predefined C Keyword., B) A function name can start with an Underscore( _ ) or A to Z or a to z., C) Default return type of any function is an Integer., D) All the above., Answer [=], , D, 3) Choose a correct statement about C Function.?, main(), {, printf("Hello");, }, , A) "main" is the name of default must and should Function., B) main() is same as int main(), C) By default, return 0 is added as the last statement of a function without, specific return type., D) All the above, Answer [=], , D, 4) A function which calls itself is called a ___ function., A) Self Function, B) Auto Function, C) Recursive Function, D) Static Function
Page 92 :
Answer [=], , C, 5) What is the output of C Program with Functions.?, int main(), {, , void show(), {, printf("HIDE");, }, , show();, , return 0;, }, , A) No output, B) HIDE, C) Compiler error, D) None of the above, Answer [=], , B, Explanation:, Notice that show() function is defined inside main() function. It will not, produce a compile error. But, it is not recommended to define a, FUNCTION INSIDE A FUNCTION. DO NOT DO., 6) What is the output of C Program with functions.?, void show();, , int main(), {, show();, printf("ARGENTINA ");, return 0;, }
Page 93 :
void show(), {, printf("AFRICA ");, }, , A) ARGENTINA AFRICA, B) AFRICA ARGENTINA, C) ARGENTINA, D) Compiler error, Answer [=], , B, Explanation:, First show() function is called. So it prints AFRICA first., 7) What is the output of C Program with functions.?, int main(), {, show();, printf("BANK ");, return 0;, }, , void show(), {, printf("CURRENCY ");, }, , A) CURRENCY BANK, B) BANK CURRENCY, C) BANK, D) Compiler error, Answer [=], , D, Explanation:, Yes. Compiler error. Before calling the show(); function, its Function, Prototype should be declared before outside of main() and before, main()., void show();
Page 94 :
int main(), {, show();, printf("BANK ");, return 0;, }, , 8) How many values can a C Function return at a time.?, A) Only One Value, B) Maximum of two values, C) Maximum of three values, D) Maximum of 8 values, Answer [=], , A, Explanation:, Using a return val; statement, you can return only one value., 9) What is the output of a C program with functions.?, void show();, , void main(), {, show();, printf("RAINBOW ");, , return;, }, , void show(), {, printf("COLOURS ");, }, , A) RAINBOW COLOURS
Page 95 :
B) COLOURS RAINBOW, C) COLOURS, D) Compiler error, Answer [=], , B, Explanation:, VOID functions should not return anything. RETURN; is returning, nothing., 1. First void main() return; nothing. Still it is valid., 2. Second void show() function is NO RETURN statement. It is also, valid., 10) What is the output of C Program.?, void show();, , void main(), {, printf("PISTA ");, show();, }, , void show(), {, printf("CACHEW ");, return 10;, }, , A) PISTA CACHEW, B) CASHEW PISTA, C) PISTA CASHEW with compiler warning, D) Compiler error, Answer [=], , C, Explanation:, void show() function should not return anything. So return 10; is not, recommended., 11) What is the output of C Program with functions.?, int show();
Page 96 :
void main(), {, int a;, printf("PISTA COUNT=");, a=show();, printf("%d", a);, }, , int show(), {, return 10;, }, , A) PISTA COUNT=, B) PISTA COUNT=0, C) PISTA COUNT=10, D) Compiler error, Answer [=], , C, Explanation:, int show() function returns TEN (10). 10 is assigned to a at a=show()., 12) What is the output of C Program with functions.?, void main(), {, int a;, printf("TIGER COUNT=");, a=show();, printf("%d", a);, }, , int show(), {, return 15;, return 35;
Page 97 :
}, , A) TIGER COUNT=15, B) TIGER COUNT=35, C) TIGER COUNT=0, D) Compiler error, Answer [=], , A, Explanation:, More than one return statement will not cause Compiler Error. But only, FIRST return STATEMENT is executed. Anything after return 15; is not, reachable., 13) What are types of Functions in C Language.?, A) Library Functions, B) User Defined Functions, C) Both Library and User Defined, D) None of the above, Answer [=], , C, 14) What is the output of C program with functions.?, int show();, , void main(), {, int a;, a=show();, printf("%d", a);, }, , int show(), {, return 15.5;, return 35;, }, , A) 15.5, B) 15, C) 0
Page 98 :
D) Compiler error, Answer [=], , B, Explanation:, It is perfectly Okay to return a float number 15.5 as an Integer inside, int show() function. 15.5 is demoted to integer as 15 and returned., , 15) What is the output of C Program.?, int myshow(int);, , void main(), {, myshow(5);, myshow(10);, }, , int myshow(int b), {, printf("Received %d, ", b);, }, , A) Received 5, Received 10,, B) Received 10, Received 5,, C) Received 0, Received 0,, D) Compiler error, Answer [=], , A, Explanation:, Notice the function prototype declaration int myshow(int). If you, declare wrong either Compiler warning or error is thrown. myshow(5), passes number 5. 5 is received as variable int b., 16) What is the output of C Program with functions and pointers.?, int myshow(int);, , void main()
Page 99 :
{, int a=10;, myshow(a);, myshow(&a);, }, , int myshow(int b), {, printf("Received %d, ", b);, }, , A) Received 10, Received 10,, B) Received 10, Received RANDOMNumber,, C) Received 10, Received RANDOMNumber, with a compiler warning, D) Compiler error, Answer [=], , C, Explanation:, a is 10. &a is the address of the variable a which is a random memory, location. To receive an address, int myshow(int b) should be rewritten, as int myshow(int *k)., 17) What is the output of C Program with functions and pointers.?, int myshow(int *);, , void main(), {, int a=10;, myshow(&a);, }, , int myshow(int *k), {, printf("Received %d, ", *k);, }, , A) Received RANDOMNumber,
Page 100 :
B) Received 10,, C) Received 10,, D) Compiler error, Answer [=], , C, Explanation:, It is called Passing a variable by reference. You are passing &a instead, of a. Address of a or &a is received as int *k. Observe the function, prototype declaration before main(), int myshow(int *)., 18) What is the output of C Program with functions and pointers.?, void myshow(int *);, , void main(), {, int a=10;, printf("%d ", a);, myshow(&a);, printf("%d", a);, , }, , void myshow(int *k), {, *k=20;, }, , A) 10 10, B) 20 20, C) 10 20, D) Compiler error, Answer [=], , C, Explanation:, You passed &a instead of a into myshow(int) function. *k=20 changes, the valued of passed variable passed by reference., 19) What is the output of C Program with functions.?, void myshow(int);
Page 101 :
void main(), {, int a=10;, printf("%d ", a);, myshow(a);, printf("%d", a);, , }, , void myshow(int k), {, k=20;, }, , A) 10 10, B) 20 20, C) 10 20, D) Compiler error, Answer [=], , A, Explanation:, You passed variable a directly by value. myshow(a). k=20 will not, actually change the variable a as variable k and variable a are, completely different. It is called Pass By Value., 20) Choose correct statements about C Language Pass By Value., A) Pass By Value copies the variable value in one more memory location., B) Pass By Value does not use Pointers., C) Pass By Value protects your source or original variables from changes in, outside functions or called functions., D) All the above, Answer [=], , D
Page 102 :
SET-2, 1) What is the limit for number of functions in a C Program.?, A) 16, B) 31, C) 32, D) None of the above, Answer [=], , D, Explanation:, Yes. There is no limit on the number of functions in a C Program., , 2) Every C Program should contain which function.?, A) printf(), B) show(), C) scanf(), D) main(), Answer [=], , D, Explanation:, main() is a compulsory function with or without returning anything., void main(){}, int main(){return 0;}, , 3) What is the minimum number of functions to be present in a C, Program.?, A) 1, B) 2, C) 3, D) 4, Answer [=], , A, Explanation:, At least there will be one function which is main() function., , 4) What is the output of C Program with functions.?, static void show();, , int main(), {, printf("ROCKET ");, show();, return 0;, }, , static void show()
Page 103 :
{, printf("STATIC");, }, A) ROCKET, B) ROCKET STATIC, C) STATIC ROCKET, D) Compiler error, Answer [=], , B, Explanation:, Yes. A function can be static. Remember that a static variable or function has only FILE scope. You can, use this function outside of the defined file even with extern static void show() prototype declaration., , 5) What is the maximum number of statements that can present in a, C function.?, A) 64, B) 128, C) 256, D) None of the above, Answer [=], , D, Explanation:, There is no limit on the number of statements that can present in a C Function., , 6) What characters are allowed in a C function name identifier.?, A) Alphabets, Numbers, %, $, _, B) Alphabets, Numbers, Underscore ( _ ), C) Alphabets, Numbers, dollar $, D) Alphabets, Numbers, %, Answer [=], , B, Explanation:, Remember that a C function name can not start with a number but it can contain contain numbers after, 1st character is either an Underscore ( _ ) or an Alphabet., , 7) What is the output of C Program with functions and pointers.?, int main(), {, int b=25;, //b memory location=1234;, int *p = b;, printf("%d %d", b, p);, , return 0;, }
Page 104 :
A) 25 1234, B) 25 0, C) 25 25, D) Compiler error, Answer [=], , C, Explanation:, Integer Pointer *p copied the value of b to a new memory location. Its is same as int p= b;. Only p=&b, points to the same memory of b., , 8) What is the output of C Program with functions and pointers.?, int main(), {, int b=25;, //b memory location=1234;, int *p;, p=&b;, printf("%d %d %d", &b, p);, return 0;, }, A) 25 25, B) 1234 1234, C) 25 1234, D) 1234 25, Answer [=], , B, Explanation:, Integer pointer is declared by int *p. p=&b makes pointer P to point the address of b. So &b and p hold, only address., , 9) What do you call STAR * and Ampersand & in a c program, context.?, int a=10, *p;, p = &a;, printf("%d %d", a, *p);, A) * = ADDRESS OF operator, & = VALUE AT operator, B) * = ADDRESS OF operator, & = ADDRESS OF operator, C) * = VALUE AT operator, & = ADDRESS OF operator, D) * = VALUE AT operator, & = VALUE AT operator, Answer [=], , C
Page 105 :
Explanation:, &b gives ADDRESS OF b. *p gives VALUE AT memory location of b., , 10) What is the output of C Program with functions.?, #include, int sum(int,int);, int main(), {, int a=5, b=10, mysum;, mysum = sum(a,b);, printf("SUM=%d ", mysum);, printf("SUM=%d", sum(10,20));, return 0;, }, int sum(int i, int j), {, return (i+j);, }, A) SUM=15 SUM=30, B) SUM=30 SUM=15, C) SUM=15 SUM=15, D) SUM=30 SUM=30, Answer [=], , A, Explanation:, You can call a function sum(10,20) inside another function printf directly., , 11) Arguments passed to a function in C language are called ___, arguments., A) Formal arguments, B) Actual Arguments, C) Definite Arguments, D) Ideal Arguments, Answer [=], , B, , 12) Arguments received by a function in C language are called ___, arguments., A) Definite arguments, B) Formal arguments, C) Actual arguments, D) Ideal arguments, Answer [=], , B
Page 106 :
13) Choose a corrects statement about C language function, arguments., A) Number of arguments should be same when sending and receiving, B) Type of each argument should match exactly, C) Order of each argument should be same, D) All the above, Answer [=], , D, Explanation:, 20.0 is float. But char j is Character type. So, it is a mismatch. Here exactly two arguments are passed and, two arguments are received., int main(), {, sum(10, 20.0);, return 0;, }, int sum(int i, char j), {, return 10;, }, , 14) What is the output of C program with functions.?, int main(), {, printf("funny=%d" , funny());, return 0;, }, funny(), {, , }, A) funny=, B) funny=1, C) funny=0, D) Compiler error, Answer [=], , 15) What is the output of C Program with functions.?
Page 107 :
void funny2();, int main(), {, printf("funny2=%d" , funny2());, return 0;, }, void funny2(), {, , }, A) funny2=, B) funny2=0, C) funny2=1, D) Compiler error, Answer [=], , D, Explanation:, void function does not return anything., , 16) Choose a correct statement with C Functions., A) A function can call any other function any number of times, B) You can write any function in any order in a multi function C File., C) You can refer to or call any function using a Pointer also., D) All the above, Answer [=], , D, , 17) Choose a non Library C function below., A) printf(), B) scanf(), C) fprintf(), D) printf2(), Answer [=], , D, Explanation:, fprintf is used along with files. There is no library function PRINTF2()., , 18) What is the default return value of a C function if not, specified explicitly.?, A) -1, B) 0, C) 1, D) None of the above, Answer [=], , C, Explanation:, int funny()
Page 108 :
{, //return 0; is added by compiler., }, , 19) What do you call this C Function calling itself.?, int funny2(), {, funny2(num);, }, A) Indefinite Function, B) Definite Function, C) Cursive Function, D) Recursive Function, Answer [=], , D, Explanation:, This recursive function hangs the CPU as there is no come out condition with IF., , 20) What is the output of C Program with functions.?, int bunny(int,int);, int main(), {, int a, b;, a = bunny(5, 10);, b = bunny(10, 5);, printf("%d %d", a, b);, return 0;, }, int bunny(int i, int j), {, return (i, j);, }, A) 5 10, B) 10 5, C) 5 5, D) Compiler error, Answer [=], , B, Explanation:
Page 109 :
Do not try to put the same return (a,b). It is a bad practice to return 2 values at a time. You can return, only one value. Value right side value return j works every time., , SET-3, 1) What are the data type of variables that can be returned by a C, Function.?, A) int, float, double, char, B) struct, enum, C) Pointers to variables, arrays, functions, struct variables, enum variables etc, D) All the above, Answer [=], , D, 2) What is the output of a C Program with functions and pointers.?, void texas(int *,int *);, int main(), {, int a=11, b=22;, printf("Before=%d %d, ", a, b);, texas(&a, &b);, printf("After=%d %d", a, b);, , return 0;, }, void texas(int *i, int *j), {, *i = 55;, *j = 65;, }, , A) Before=11 22, After=11 22, B) Before=11 22, After=55 65, C) Before=11 22, After=0 0, D) Compiler error, Answer [=], , B, Explanation:
Page 110 :
a and b are passed through Call By Reference &a, &b. So the passed, addresses are collected by variables i and j. So changes made using, pointers are retained even after the function execution is over., 3) What is the output of C Program with functions.?, int main(), {, int a = 66;, printf("%d %d %d,\n", a, ++a, a++);, a = 66;, printf("%d %d %d,\n", ++a, a++, a);, a = 66;, printf("%d %d %d", ++a, a, a++);, return 0;, }, , A), 68 68 66,, 68 66 66,, 68 68 66, , B), 68 68 66,, 66 66 68,, 68 68 66, , C), 68 68 66,, 68 66 68,, 68 68 66, , D), 68 68 66,, 68 66 68,, 68 68 68, Answer [=], , C
Page 111 :
Explanation:, Order of processing arguments is right to left. First keep 3 placeholder, buckets. Right to left check for higher priority of variables like ++a or, a++ etc. Always process higher priority variables first. At last, fill the, value of low priority variable a., 4) What is the output of a C program.?, int main(), {, int a = 1;, printf("%d %d %d,\n", a, ++a, a++);, a = 1;, printf("%d %d %d,\n", ++a, a++, a);, a = 1;, printf("%d %d %d", ++a, a, a++);, return 0;, }, , A), 3 3 1,, 3 3 3,, 3 3 1, , B), 3 1 1,, 3 1 3,, 3 3 1, , C), 3 3 1,, 3 1 3,, 3 1 1, , D), 3 3 1,, 3 1 3,, 3 3 1
Page 112 :
Answer [=], , D, 5) What is the output of a C Program.?, void show(int,int,int);, int main(), {, int a = 1;, show(++a, a++, a);, return 0;, }, void show(int i, int j, int k), {, printf("%d %d %d,\n", i, j, k);, }, , A), 1 1 3,, , B), 3 1 3,, , C), 3 1 1,, , D), 3 3 3,, Answer [=], , B, Explanation:, 1) ++a, 2) a++ 3) a. Second and third arguments have higher priority, than third parameter A. So Second is processed. Than first is processed., Finally the actual value of a at that point is given to third place holder., 6) What is the output of C Program with pointers.?, int main(), {, int a = 4;
Page 113 :
int *p;, p=&a;, while(*p > 0), {, printf("%d ", *p);, (*p)--;, }, return 0;, }, , A) 0 0 0 0, B) 4 4 4 4, C) 4 3 2 1, D) Compiler error, Answer [=], , C, Explanation:, Notice the decrement operation on variable "a" using (*p)--. Without, parantheses, variable is not decremented but memory location pointed, is decremented and pointed to a garbage value., 7) What is the output of C Program with functions.?, void show();, int show();, int main(), {, printf("ANT\n");, return 0;, }, void show(), {, printf("Integer") ;, }, int show(), {, printf("Void");, }
Page 114 :
A) ANT, B) Integer, C) Void, D) Compiler error, Answer [=], , D, Explanation:, You can not declare same function with different return types. Here, both void show() and int show() can not be written., , 8) What is the output of C Program with functions.?, void show(int);, void show(float);, int main(), {, printf("ANT\n");, return 0;, }, void show(int a), {, printf("Integer") ;, }, void show(float b), {, printf("Void");, }, , A) Integer Void, B) ANT Integer Void, C) ANT, D) Compiler error, Answer [=], , D, Explanation:
Page 115 :
You can not re declare and redefine the a function with same name and, different arguments. Function name can not be duplicate in any, combination., 9) What is the output of C Program with pointers.?, int main(), {, int a=10;, int *p, **q;, p=&a;, q=&p;, printf("%d ", a);, *p=15;, printf("%d ", a);, **q=20;, printf("%d ", a);, return 0;, }, , A) 10 10 10, B) 10 0 0, C) 10 15 20, D) Compiler error, Answer [=], , C, Explanation:, Here p is pointer to an integer. q is a pointer to pointer. That is why you, should use two STARs **., 10) What is the output of C Program with pointers.?, int main(), {, int a=20;, int *p, *q;, p=&a;, q=p;, printf("%d ", a);, *p=30;
Page 116 :
printf("%d ", a);, *q=40;, printf("%d ", a);, return 0;, }, , A) 20 0 0, B) 20 20 20, C) 20 30 40, D) Compiler error, Answer [=], , C, Explanation:, P is already a pointer to an integer a. Q copied P. So Q is also a pointer, to the same integer a., 11) What is the output of C Program with pointers.?, int main(), {, int a=20;, //a memory location=1234, printf("%d %d %d", a, &a, *(&a));, return 0;, }, , A) 20 20 20, B) 20 1234 1234, C) 20 1234 20, D) 20 20 20, Answer [=], , C, Explanation:, If VALUEAT operator * and ADDRESSOF operator & are used, immediately, it is same as the variable itself. So *(&a) == a., 12) What is the output of C Program with functions.?, int main(), {, int a=20;, printf("CINEMA ");
Page 117 :
return 1;, printf("DINOSAUR");, return 1;, }, , A) CINEMA DINOSAUR, B) CINEMA, C) DINOSAUR, D) Compiler error, Answer [=], , B, Explanation:, There are two return statements in main() function. Only first return is, executed. All the statements or lines of code below first return is not, reachable and hence not executed., 13) What is the output of C Program with recursive function.?, int sum(int);, int main(), {, int b;, b = sum(4);, printf("%d", b);, , }, int sum(int x), {, int k=1;, if(x<=1), return 1;, k = x + sum(x-1);, return k;, }, , A) 10, B) 11, C) 12, D) 15
Page 118 :
Answer [=], , A, Explanation:, 4 + 3 + 2 + 1 = 10., 14) What is the output of C Program with Recursive Function.?, int mul(int);, int main(), {, int b;, b = mul(3);, printf("%d", b);, }, int mul(int x), {, if(x<=1), return 1;, return (x * mul(x-1));, }, , A) 2, B) 3, C) 6, D) 1, Answer [=], , C, Explanation:, 3*2*1 = 6., , 15) A recursive function can be replaced with __ in c language., A) for loop, B) while loop, C) do while loop, D) All the above, Answer [=], , D
Page 119 :
16) A recursive function is faster than __ loop., A) for, B) while, C) do while, D) None of the above, Answer [=], , D, Explanation:, Yes. Recursion is slow. Variable are kept and remove on STACK memory, multiple times., 17) A recursive function without If and Else conditions will, always lead to.?, A) Finite loop, B) Infinite loop, C) Incorrect result, D) Correct result, Answer [=], , B, Explanation:, Yes. To come out of recursion, you must use IF or ELSE blocks., 18) What is the C keyword that must be used to achieve expected, result using Recursion.?, A) printf, B) scanf, C) void, D) return, Answer [=], , D, Explanation:, Recursion is entirely based on RETURN value; statement., 19) How many functions are required to create a recursive, functionality.?, A) One, B) Two, C) More than two, D) None of the above, Answer [=], , A, Explanation:
Page 120 :
Only one function is required to achieve recursion. Recursion is calling, the same function within. How ever to use the value or output of all, recursive calls, at least one main() function is also required., 20) Choose a correct statement about Recursive Function in C, language., A) Each recursion creates new variables at different memory locations, B) There is no limit on the number of Recursive calls, C) Pointers can also be used with Recursion but with difficulty., D) All the above, Answer [=], , D, , ARRAY & POINTERS SET-1, 1) What is an Array in C language.?, A) A group of elements of same data type., B) An array contains more than one element, C) Array elements are stored in memory in continuous or contiguous locations., D) All the above., Answer [=], , D, 2) Choose a correct statement about C language arrays., A) An array address is the address of first element of array itself., B) An array size must be declared if not initialized immediately., C) Array size is the sum of sizes of all elements of the array., D) All the above, Answer [=], , D, 3) What are the Types of Arrays.?, A) int, long, float, double, B) struct, enum, C) char, D) All the above, Answer [=], , D, 4) An array Index starts with.?
Page 121 :
A) -1, B) 0, C) 1, D) 2, Answer [=], , B, 5) Choose a correct statement about C language arrays., A) An array size can not changed once it is created., B) Array element value can be changed any number of times, C) To access Nth element of an array students, use students[n-1] as the, starting index is 0., D) All the above, Answer [=], , D, 6) What is the output of C Program.? int main() { int a[]; a[4] =, {1,2,3,4}; printf("%d", a[0]); }, A) 1, B) 2, C) 4, D) Compiler error, Answer [=], , D, Explanation:, If you do not initialize an array, you must mention ARRAY SIZE., 7) What is the output of C Program.? int main() { int a[] =, {1,2,3,4}; int b[4] = {5,6,7,8}; printf("%d,%d", a[0], b[0]); }, A) 1,5, B) 2,6, C) 0 0, D) Compiler error, Answer [=], , A, Explanation:, It is perfectly allowed to skip array size if you are initializing at the, same time. a[0] is first element., int a[] = {1,2,3,4};
Page 122 :
8) What is the output of C Program.? int main() { char grade[] =, {'A','B','C'}; printf("GRADE=%c, ", *grade); printf("GRADE=%d",, grade); }, A) GRADE=some address of array, GRADE=A, B) GRADE=A, GRADE=some address of array, C) GRADE=A, GRADE=A, D) Compiler error, Answer [=], , B, Explanation:, Variable grade = address of first element. *grade is the first element of, array i.e grade[0]., 9) What is the output of C program.? int main() { char grade[] =, {'A','B','C'}; printf("GRADE=%d, ", *grade); printf("GRADE=%d",, grade[0]); }, A) A A, B) 65 A, C) 65 65, D) None of the above, Answer [=], , C, Explanation:, *grade == grade[0]. We are printing with %d not with %c. So, ASCII, value is printed., 10) What is the output of C program.? int main() { float marks[3], = {90.5, 92.5, 96.5}; int a=0; while(a<3) { printf("%.2f,",, marks[a]); a++; } }, A) 90.5 92.5 96.5, B) 90.50 92.50 96.50, C) 0.00 0.00 0.00, D) Compiler error, Answer [=], , B, Explanation:, 0.2%f prints only two decimal points. It is allowed to use float values, with arrays., 11) What is the output of C Program.? int main() { int a[3] =, {10,12,14}; a[1]=20; int i=0; while(i<3) { printf("%d ", a[i]);, i++; } }, A) 20 12 14
Page 123 :
B) 10 20 14, C) 10 12 20, D) Compiler error, Answer [=], , B, Explanation:, a[i] is (i+1) element. So a[1] changes the second element., 12) What is the output of C program.? int main() { int a[3] =, {10,12,14}; int i=0; while(i<3) { printf("%d ", i[a]); i++; } }, A) 14 12 10, B) 10 10 10, C) 10 12 14, D) None of the above, Answer [=], , C, Explanation:, a[k] == k[a]. Use any notation to refer to array elements., 13) What is the output of C Program.? int main() { int a[3] =, {20,30,40}; a[0]++; int i=0; while(i<3) { printf("%d ", i[a]);, i++; } }, A) 20 30 40, B) 41 30 20, C) 21 30 40, D) None of the above, Answer [=], , C, Explanation:, You can use increment and decrement operators on array variables too., 14) What is the output of C program with arrays.? int main() { int, a[3] = {20,30,40}; int b[3]; b=a; printf("%d", b[0]); }, A) 20, B) 30, C) address of 0th element., D) Compiler error, Answer [=], , D, Explanation:, You can assign one array variable to other.
Page 124 :
15) What is the output of C Program with arrays and pointers.? int, main() { int a[3] = {20,30,40}; int (*p)[3]; p=&a; printf("%d",, (*p)[0]); }, A) 20, B) 0, C) address of element 20, D) Compiler error, Answer [=], , A, Explanation:, You can not directly assign one array variable to other. But using an, array pointer, you can point to the another array. (*p) parantheses are, very important., 16) What is the output of C program with arrays and pointers.? int, main() { int a[3] = {20,30,40}; int *p[3]; p=&a; printf("%d",, *p[0]); }, A) 20, B) address of element 20, C) Garbage value, D) Compiler error, Answer [=], , D, Explanation:, To point to an array, array pointer declaration should be like (*p)[3], with parantheses. It points to array of 3 elements., 17) What is the output of C program with arrays and pointers.? int, main() { int a[3] = {20,30,40}; printf("%d", *(a+1)); }, A) 20, B) 30, C) 40, D) Compiler error, Answer [=], , B, Explanation:, *(a+0) == *a == a[0]. So *(a+1) is element at index 1. Index starts, with ZERO., 18) What is an array Base Address in C language.?, A) Base address is the address of 0th index element., B) An array b[] base address is &b[0], C) An array b[] base address can be printed with printf("%d", b);
Page 125 :
D) All the above, Answer [=], , D, 19) What is the output of C Program with arrays and pointers.?, void change(int[]); int main() { int a[3] = {20,30,40}; change(a);, printf("%d %d", *a, a[0]); } void change(int a[]) { a[0] = 10; }, A) 20 20, B) 10 20, C) 10 10, D) 20 30, Answer [=], , C, Explanation:, Notice that function change() is able to change the value of a[0] of, main(). It uses Call By Reference. So changes in called function affected, the original values., 20) An entire array is always passed by ___ to a called function., A) Call by value, B) Call by reference, C) Address relocation, D) Address restructure, Answer [=], , B, , SET-2, 1) What is the output of C program with arrays and pointers.?, int main(), {, int size=4;, int a[size];, a[0]=5;a[1]=6;, a[2]=7;a[3]=8;, printf("%d %d", *(a+2), a[1]);, }, , A) 8 6
Page 126 :
B) 7 6, C) 6 6, D) Compiler error, Answer [=], , B, Explanation:, variable size is already defined. So a[size] is allowed. *(a+2) == a[2]., 2) What is the output of C program with arrays.?, int main(), {, int ary(3)=[20,30,40];, printf("%d", a(1));, }, , A) 20, B) 30, C) 0, D) Compiler error, Answer [=], , D, Explanation:, Array should be declared and defined with Square Brackets. Use ary[2], instead of ary(2)., int ary[3]={20,30,40};, , 3) What is the output of C Program with arrays.?, int main(), {, int rollno[3]=[1001,1002,1003];, printf("%d", rollno[1]);, }, , A) 1002, B) 1003, C) address of 1002, D) Compiler error, Answer [=], , D, Explanation:
Page 127 :
You should use Flower Brackets or Braces to define elements like, {1,2,3}. It is wrong to use [1,2,3]., 4) What is the output of C program with arrays.?, int main(), {, char grade={'A','B','C'};, printf("%c", grade[0]);, }, , A) A, B) B, C) C, D) Compiler error, Answer [=], , D, Explanation:, Notice that char grade is an character variable, not Character array, variable. So declare as char grade[] = {'A','B','C'};, 5) What is the value of an array element which is not, initialized.?, A) By default Zero 0, B) 1, C) Depends on Storage Class, D) None of the above., Answer [=], , C, Explanation:, For Automatic variables, default value is garbage. For static and global, variables, default value is 0., 6) What happens when you try to access an Array variable outside, its Size.?, A) Compiler error is thrown, B) 0 value will be returned, C) 1 value will be returned, D) Some garbage value will be returned., Answer [=], , D, 7) What is the size of an array in the below C program statement.?, int main()
Page 128 :
{, int ary[9];, return 0;, }, , A) 8, B) 9, C) 10, D) None of the above, Answer [=], , B, Explanation:, Array size is 9. So memory occupied by 9 integers are kept aside by the, CPU., , 8) What is the minimum and maximum Indexes of this below array.?, int main(), {, int ary[9];, return 0;, }, , A) -1, 8, B) 0, 8, C) 1,9, D) None of the above, Answer [=], , B, Explanation:, Array index starts with 0 and ends with 8 for a 9 Size array. ary[0] to, ary[8] are meaningful., 9) Can we change the starting index of an array from 0 to 1 in any, way.?, A) Yes. Through pointers., B) Yes. Through Call by Value., C) Yes. Through Call by Reference.
Page 129 :
D) None of the above., Answer [=], , D, Explanation:, No. You can not change the C Basic rules of Zero Starting Index of an, Array., 10) What is the need for C arrays.?, A) You need not create so many separate variables and get confused while using., B) Using a single Array variable, you can access all elements of the array easily., C) Code maintainability is easy for programmers and maintainers., D) All the above., Answer [=], , D, 11) What is the output of C program with arrays.?, int main(), {, int ary[4], size=4;, printf("%d ", ary[size]);, return 0;, }, , A) 0, B) 1, C) Random number, D) Compiler error, Answer [=], , C, Explanation:, Yes. Some random number will be printed as the array is not initialized, and the index is out of range. But, you do not get any compiler error. It, is your responsibility., 12) What is the output of C Program with arrays.?, int main(), {, int ary[4];, ary[4] = {1,2,3,4};, printf("%d ", ary[2]);, return 0;
Page 130 :
}, , A) 2, B) 3, C) 0, D) Compiler error, Answer [=], , D, Explanation:, You can not initialize the array in next line or statement once its type, and size is defined first., int ary[4]={1,2,3,4}; //works, , 13) What is the output of C Program with arrays.?, int main(), {, int ary[3]={1,2};, printf("%d %d",ary[2]);, return 0;, }, , A) 0, B) 2, C) Garbage value, D) Compiler error, Answer [=], , C, Explanation:, Though you initialized only two elements in a 3 Size array, it is valid., Third element is a garbage value., 14) What is a multidimensional array in C Language.?, A) It is like a matrix or table with rows and columns, B) It is an array of arrays, C) To access 3rd tow 2nd element use ary[2][1] as the index starts from 0 row or, column, D) All the above., Answer [=], , D
Page 131 :
15) If an integer array pointer is incremented, how many bytes, will be skipped to reach next element location.?, A) 1, B) 2, C) 8, D) None of the above, Answer [=], , B, Explanation:, In Turbo C, integer occupies 2 bytes. So in an integer array, if, array pointer is incremented, it will reach the next element after two, bytes. In this below 4 element integer array, elements are available at, 1001, 1003, 1005 and 1007 byte addresses., 1001 1002 1003 1004 1005 1006 1007 1008., , 16) What is the output of C Program with arrays and pointers.?, int main(), {, int ary[] = {10,20,30}, *p;, p = &ary[0];, int i=0;, while(i<3), {, printf("%d ", *p);, p++;, i++;, }, return 0;, }, , A) 10 10 10, B) 10 20 20, C) 10 20 30, D) randomvalue randomvalue randomvalue, Answer [=]
Page 132 :
C, Explanation:, First get the address of 1st element &ary[0]. Increment the pointer P to, reach next element of the array., 17) What is the function used to allocate memory to an array at, run time with Zero initial value to each.?, A) calloc(), B) malloc(), C) palloc(), D) kalloc(), Answer [=], , A, Explanation:, Yes. calloc() initialized the elements to 0. malloc() does not initialize., So garbage values will be there., 18) What is the function used to allocate memory to an array at, run time without initializing array elements.?, A) calloc(), B) malloc(), C) palloc(), D) kalloc(), Answer [=], , B, 19) Choose a correct Syntax for malloc() function to allocate, memory to an array at run time., A), int *p;, p = (int*)malloc(10*sizeof(int));, , B), int *p;, p = (int*)malloc(10,sizeof(int));, , C), int *p;, p = (int*)malloc(sizeof(int), 10);, , D), int *p;
Page 133 :
p = (int*)malloc(10*sizeof(int *));, Answer [=], , A, Explanation:, It allocates memory to hold 10 integers in an array., 20) What is the syntax of CALLOC to allocate memory to an array at, runtime.?, A), int *p;, p = (int*)calloc(10, sizeof(int));, , B), int *p;, p = (int*)calloc(10*sizeof(int));, , C), int *p;, p = (int*)calloc(sizeof(int), 10);, , D), int *p;, p = (int*)calloc(10, sizeof(int *));, Answer [=], , A, , SET-3, 1) What is the dimension of the C array int ary[10][5].?, A) 1, B) 2, C) 5, D) 10, Answer [=], , B, Explanation:, See the number of [ ] square bracket pairs. Here there are 2 ary[10][5]. So the dimension is TWO 2., , 2) What is the dimension of the below C Array.?
Page 134 :
int ary[]={1,3,5,7};, A) 1, B) 2, C) 3, D) 5, Answer [=], , A, Explanation:, It is a Single Dimension Array. Only [] one pair of square brackets is present., , 3) Choose a correct statement with array pointers., A) It is valid to add an integer number to an array pointer. Result can be anything., B) It is valid to subtract an integer number from array pointer. Result can be anything., C) Difference of pointers to two elements of an array gives the difference between their indexes., D) All the above, Answer [=], , D, , 4) Choose correct statement about C array pointers., A) You can compare two array elements with *p == *(p+i), B) You can compare two pointers with p1==p2., C) Accessing out of bounds index element is valid and it returns a garbage value., D) All the above., Answer [=], , D, , 5) What is the output of C Program with arrays.?, int main(), {, int ary[] = {1, 3, 5};, printf("%d %d", ary[-1], ary[4]);, return 0;, }, A) 1 5, B) 0 0, C) Compiler error, D) None of the above, Answer [=], , D, Explanation:, You are accessing -1 index and 4 index which is outside the limit 0 to 2. You get only garbage values., , 6) What is the output of C Program with arrays.?, int main(), {, static int ary[] = {1, 3, 5};
Page 135 :
printf("%d %d", ary[-1], ary[5]);, return 0;, }, A) 0 0, B) -1 -1, C) Compiler error, D) None of the above, Answer [=], , A, Explanation:, 0 0 is the answer. Storage Class static makes all uninitialized variables to hold default ZERO values., , 7) What is the output of C Program with arrays and pointers.?, int main(), {, int ary[] = {11, 33, 55};, int *p, *q;, p = ary;, q = ary+2;, printf("%d %d",*p, *q);, return 0;, }, A) 11 55, B) 11 13, C) 11 33, D) Compiler error, Answer [=], , A, Explanation:, Incrementing a pointer points to the address of next element. ary points to first element. ary +1 points to, second element. ary+2 points to the third element., , 8) Difference between C Arrays, ary[10] and cry[10][10] is.?, A) ary[10] is a single dimensional array. cry[10][10] is a Multidimensional array., B) ary[10] is a multidimensional array. cry[10][10] is a single dimensional array., C) Size of ary[10] is sizeof(10* int). Size of cry[10][10] is sizeof(10*int)., D) None of the above., Answer [=], , A, Explanation:, One square bracket = Single Dimension or One dimension.
Page 136 :
9) Array of Arrays is also called.?, A) Multi Data Array, B) Multi Size Array, C) Multi Dimensional Array, D) Multi Byte Array, Answer [=], , C, , 10) What is the output of C program with multidimensional array.?, int main(), {, int ary[3][2] = {1,2,3,4,5,6};, printf("%d %d", ary[0][0], ary[2][1]);, return 0;, }, A) 2 5, B) 1 6, C) 1 5, D) 2 6, Answer [=], , B, Explanation:, [3] represents 3 rows. [2] represents 2 columns. So each row contains two elements. Index of row and, column start with ZERO 0. So ary[2][1] represents 3rd row, 2nd element., , 11) What is the output of C program with multidimensional arrays.?, int main(), {, int ary[3][] = {6,5,4,3,2,1};, printf("%d %d", ary[0][0], ary[2][1]);, return 0;, }, A) 6 1, B) 6 2, C) 5 1, D) Compiler error, Answer [=], , D, Explanation:, ary[3][] has missing column count. Column count is a must for any multidimensional array., , 12) What is the output of C program with multidimensional arrays.?, int main(), {
Page 137 :
int ary[][3] = {6,5,4,3,2,1};, printf("%d %d", ary[0][0], ary[1][0]);, return 0;, }, A) 6 2, B) 6 3, C) 6 1, D) Compiler error, Answer [=], , B, Explanation:, ary[][3] divides all 6 elements into two rows each containing 3 elements. 6/col = 6/3 = 2 rows. {{6,5,4},, {3,2,1}}, , 13) Choose an alternative definition of C Multidimensional array.?, int ary[][3] = {6,5,4,3,2,1};, A) int ary[2][3] = {6,5,4,3,2,1};, B) int ary[2][3] = {{6,5,4},{3,2,1}};, C) int ary[][3] = {{6,5,4},{3,2,1}};, D) All the above., Answer [=], , D, , 14) What is the output of C Program with arrays.?, int main(), {, int ary[][2][3] = {, {{1,2,3},{4,5,6}},, {{7,8,9},{10,11,12}}, };, printf("%d %d", ary[0][0][0], ary[1][1][1]);, return 0;, }, A) 1 12, B) 1 11, C) 7 12, D) 1 6, Answer [=], , B, Explanation:, a[][2][3] has missing first dimension. It is valid to ignore first dimensional value if you want. 1st dimension, = 12/(2*3) = 12/6 = 2.
Page 138 :
15) Choose a correct statement about a C Multidimensional array., A) First Dimension size is optional when initializing the array at the same time., B) Last Dimension size is optional when initializing the array at the same time., C) It is a must to specify all dimensions of a multidimensional array., D) Memory locations of elements of a multidimensional array is not sequential., Answer [=], , A, Explanation:, int ary[] = {1,2,3};, int bry[][2] = {{1,2},{3,4}}, , 16) What is the output of C Program.?, int main(), {, int ary[2][2][3] = {, {{1,2,3},{4,5,6}},, {{7,8,9},{10,11,12}}, };, int *p;, p = &ary;, printf("%d %d",*p, *p+11);, return 0;, }, A) 1 11, B) 1 12, C) 2 12, D) Compiler error, Answer [=], , B, Explanation:, *p points to the first element. *p + 11 is the 12th element which is 12 in the array. It is same as, ary[1][1][2]., , 17) What is the output of C Program.?, int main(), {, int ary[2][2][3] = {, {{1,2,3},{4,5,6}},
Page 139 :
{{7,8,9},{10,11,12}}, };, printf("%d",*(*(*(ary+1)+ 1)+2));, return 0;, }, A) 10, B) 11, C) 12, D) Compiler error, Answer [=], , C, Explanation:, *(*(*(ary+i)+ )+k) = ary[i][j][k], , 18) Choose a correct C Statement to choose number 66 in the array,, int ary[3][2] = {{11,22},{33,44},{55,66}};, A) ary[2][1], B) *(*(ary+2)+1), C) *ary[2]+1, D) All the above, Answer [=], , D, , 19) A multidimensional array of dimension N is a collection of.?, A) Single Dimensional Arrays, B) N dimensional arrays, C) N-1 dimension arrays, D) N-2 dimension arrays, Answer [=], , C, Explanation:, A 4 dimensional array is a collection of 3 dimensional arrays., , 20) Choose a correct statement about a Multidimensional array and, pointer.?, A) int *ptr[N] is an array of N integer pointers. Size is N * sizeof(1*int)., B) int (*ptr)[N] is a pointer to an array of N elements. Size of ptr is size of 1 integer., C) An multidimensional array or a single dimensional array can contain pointer elements., D) All the above, Answer [=], , D, , STRING SET-1, 1) What is a String in C Language.?, A) String is a new Data Type in C, B) String is an array of Characters with null character as the last element of array.
Page 140 :
C) String is an array of Characters with null character as the first element of array, D) String is an array of Integers with 0 as the last element of array., Answer [=], , B, , 2) Choose a correct statement about C String., char ary[]="Hello..!";, A) Character array, ary is a string., B) ary has no Null character at the end, C) String size is not mentioned, D) String can not contain special characters., Answer [=], , A, Explanation:, It is a simple way of creating a C String. You can also define it like the below. \0 is mandatory in this, version. char ary[] = {'h','e','l','l','o','\0'};, , 3) What is the Format specifier used to print a String or, Character array in C Printf or Scanf function.?, A) %c, B) %C, C) %s, D) %w, Answer [=], , C, Explanation:, char ary[]="Hello..!";, printf("%s",ary);, , 4) What is the output of C Program with Strings.?, int main(), {, char ary[]="Discovery Channel";, printf("%s",ary);, return 0;, }, A) D, B) Discovery Channel, C) Discovery, D) Compiler error, Answer [=], , B, Explanation:, %s prints the while character array in one go., , 5) What is the output of C Program with Strings.?
Page 141 :
int main(), {, char str[]={'g','l','o','b','e'};, printf("%s",str);, return 0;, }, A) g, B) globe, C) globe\0, D) None of the above, Answer [=], , D, Explanation:, Notice that you have not added the last character \0 in the char array. So it is not a string. It can not know, the end of string. So it may print string with some garbage values at the end., , 6) What is the output of C Program with Strings.?, int main(), {, char str[]={'g','l','o','b','y','\0'};, printf("%s",str);, return 0;, }, A) g, B) globe, C) globe\0, D) Compiler error, Answer [=], , B, Explanation:, Adding a NULL or \0 at the end is a correct way of representing a C string. You can simple use char, str[]="globy". It is same as above., , 7) How do you convert this char array to string.?, char str[]={'g','l','o','b','y'};, A) str[5] = 0;, B) str[5] = '\0', C) str[]={'g','l','o','b','y','\0'};, D) All the above, Answer [=], , D
Page 142 :
8) What is the output of C Program.?, int main(), {, int str[]={'g','l','o','b','y'};, printf("A%c ",str);, printf("A%s ",str);, printf("A%c ",str[0]);, return 0;, }, A) A A A, B) A Ag Ag, C) A*randomchar* Ag Ag, D) Compiler error, Answer [=], , C, Explanation:, Notice that STR is not a string as it is not a char array with null at the end. So STR is the address of array, which is converted to Char by %c. If you use %s, it prints the first number converted to char., , 9) What is the output of C Program with arrays.?, int main(), {, char str[]={"C","A","T","\0"};, printf("%s",str);, return 0;, }, A) C, B) CAT, C) CAT\0, D) Compiler error, Answer [=], , D, Explanation:, Yes. You can not use Double Quotes " to represent a single character. Correct way is 'C' not "C". You, should use Single Quotes around a single character constant., , 10) What is the maximum length of a C String.?, A) 32 characters, B) 64 characters, C) 256 characters
Page 143 :
D) None of the above, Answer [=], , D, Explanation:, Maximum size of a C String is dependent on implemented PC memory. C does not restrict C array size or, String Length., , 11) What is the output of C program with strings.?, int main(), {, char str1[]="JOHN";, char str2[20];, str2= str1;, printf("%s",str2);, return 0;, }, A) JOHN, B) J, C) JOHN\0, D) Compiler error, Answer [=], , D, Explanation:, You can not assign one string to the other. It is an error. ", error: assignment to expression with array type, , 12) What is the output of C Program with arrays.?, int main(), {, char str[25];, scanf("%s", str);, printf("%s",str);, return 0;, }, //input: South Africa, A) South, B) South Africa, C) S, D) Compiler error, Answer [=], , A
Page 144 :
Explanation:, SCANF can not accept a string with spaces or tabs. So SCANF takes only South into STR., , 13) What is the output of C program with strings.?, int main(), {, char str[2];, scanf("%s", str);, printf("%s",str);, return 0;, }, //Input: South, A) So, B) South, C) Compiler error, D) None of the above, Answer [=], , B, Explanation:, In C Arrays, Overflow or Out of Bounds is not checked properly. It is your responsibility to check., , 14) What is the output of C Program with strings.?, int main(), {, char str[2];, int i=0;, scanf("%s", str);, while(str[i] != '\0'), {, printf("%c", str[i]);, i++;, }, return 0;, }, //Input: KLMN, A) KL, B) KLMN, C) Compiler error, D) None of the above, Answer [=]
Page 145 :
B, Explanation:, It always overwrites the next memory locations of the array. It is your responsibility to check bounds., Scanf automatically adds a '\0' at the end of entered string., , 15) What is the output of C Program with String Pointer.?, int main(), {, char country[]="BRAZIL";, char *ptr;, ptr=country;, while(*ptr != '\0'), {, printf("%c", *ptr);, ptr++;, }, return 0;, }, A) B, B) BRAZIL, C) Compiler error, D) None of the above, Answer [=], , B, Explanation:, *ptr != '\0' is the main part of traversing a C String., , 16) How do you accept a Multi Word Input in C Language.?, A) SCANF, B) GETS, C) GETC, D) FINDS, Answer [=], , B, Explanation:, Yes. gets(str) fills the array str with the input given by the user., , 17) Choose a correct C Statement about Strings., A) PRINTF is capable of printing a multi word string., B) PUTS is capable of printing a multi word string., C) GETS is capable of accepting a multi word string from console or command prompt, D) All the above, Answer [=]
Page 146 :
D, , 18) What is the output of C Program with String Pointers.?, int main(), {, char *p1 = "GOAT";, char *p2;, p2 = p1;, printf("%s", p2);, }, A) G, B) GOAT, C) Compiler error, D) None of the above, Answer [=], , B, Explanation:, Yes. You can assign one String pointer to another. But you can not assign a normal character array, variable to other like STR2 = STR1. It is an error., , 19) What is the output of C Program with String arrays.?, int main(), {, char *p1 = "GOAT";, char *p2;, p2 = p1;, p2="ANT";, printf("%s", p1);, }, A) ANT, B) GOAT, C) G, D) A, Answer [=], , B, Explanation:, *p1 and *p2 are completely pointing different memory locations. So, p1 value is not touched., , 20) What is the output of C Program with String Arrays.?, int main(), {, char p[] = "GODZILLA";
Page 147 :
int i=0;, while(p[i] != '\0'), {, printf("%c",*(p+i));, i++;, }, }, A) G, B) GODZILLA, C) Compiler error, D) None of the above, Answer [=], , B, Explanation:, Notice the usage of *(p+i). Remember that, p[i] == *(p+i) == *(i+p) == i[p], , SET-2, 1) What is the ASCII value of NULL or \0.?, A) 0, B) 1, C) 10, D) 49, Answer [=], , A, Explanation:, ASCII value of NULL character is ZERO 0., 2) A character constant is enclosed by.?, A) Left Single Quotes, B) Right Single Quotes, C) Double Quotes, D) None of the above, Answer [=], , B, Explanation:, char ary[] = {'a','b','\0'}., char bry[] = {`a`,`b`,`c`}; is wrong as it uses Left Single Quotes., 3) Choose a correct statement about C String.
Page 148 :
A) A string is a group of characters enclosed by double quotes., B) If a string is defined with double quotes, NULL is automatically added at the, end., C) Size of a string is without counting NULL character at the end, D) All the above, Answer [=], , D, 4) A C string elements are always stored in.?, A) Random memory locations, B) Alternate memory locations, C) Sequential memory locations, D) None of the above, Answer [=], , C, 5) What is the output of C program with strings.?, int main(), {, char var='b';, printf("%d ", sizeof("a"));, printf("%d ", sizeof('b'));, printf("%d ", sizeof(10));, printf("%d ", sizeof(var));, }, //int size is 2 bytes, , A) 1 1 1 1, B) 2 1 2 1, C) 2 2 2 1, D) 2 2 2 2, Answer [=], , C, Explanation:, sizeof('b') is 2 because 'b' is converted to ASCII number which is, integer. sizeof(var) is printed as expected. size("a") is two because, NULL occupies 1 byte., 6) What is the output of C program with strings.?, int main(), {
Page 149 :
char str[]="JACKIE CHAN";, int i=0;, while(str[i] != 0), {, printf("%c",str[i]);, i++;, }, return 0;, }, , A) JJJJJJ JJJJ, B) JACKIE CHAN, C) Compiler error, D) None of the above, Answer [=], , B, Explanation:, Yes. You can check for end of a string with ASCII ZERO 0. ASCII value, of NULL or \0 is ZERO., 7) What is the output of C program with strings.?, int main(), {, char str[]="ANDAMAN";, int i=0;, while(str[i] != '\0'), {, printf("%c",str[i]);, i++;, }, return 0;, }, , A) AAAAAAA, B) ANDAMAN, C) Compiler error, D) None of the above, Answer [=]
Page 150 :
B, , 8) What is the output of C program with strings.?, int main(), {, char str[]="MALDIVES";, printf("%s ",str);, puts(str);, return 0;, }, , A) MALDIVES, B) MALDIVES MALDIVES, C) M MALDIVES, D) None of the above, Answer [=], , B, Explanation:, PUTS prints strings without any format specifier like %s., 9) What is the output of C program with strings.?, int main(), {, char str[3]="SUNDAY";, printf("%s",str);, }, , A) SUN, B) SUNgarbagevalues, C) compiler error, D) None of the above, Answer [=], , B, Explanation:, You get C warning., warning: initializer-string for array of chars is too long
Page 151 :
10) Choose a correct C statement about String functions.?, A) int n=strlen("abc") returns 3., B) strupr("abc") returns ABC, C) strlwr("Abc") returns abc, D) All the above, Answer [=], , D, 11) Choose a correct C statement about String functions.?, A) strrev("abcD") returns Dcba., B) strcmp("abc", "bcd") returns a negative number, C) strcmp("234","123") returns a positive number, D) All the above, Answer [=], , D, 12) Choose a correct C statement about String functions.?, A) toupper('a') returns A, B) tolower('D') returns d., C) strcmp("123","12345") returns a negative number, D) All the above, Answer [=], , D, 13) What is the output of C program.?, int main(), {, char str1[]="JAMES,";, char str2[15]="BOND ";, strcat(str2,str1);, printf("%s",str2);, printf("%s",str1);, }, , A) JAMES BOND,JAMES,, B) JAMES,JAMES,, C) BOND JAMES,JAMES,, D) None of the above, Answer [=], , C, Explanation:
Page 153 :
16) What is the output of C program with array of pointers to, strings.?, int main(), {, char *code[]={"IN","USA","K"};, printf("%s", code[1]);, return 0;, }, , A) IN, B) U, C) USA, D) Compiler error, Answer [=], , C, Explanation:, It is an array of arrays. Using an array of pointers to strings, we can, save memory. Different strings can have different lengths. Other wise,, max length of any element should be the length of all elements. It, wastes space., 17) What is the output of C program with String arrays.?, int main(), {, char code[3][4]={"IN","USA","K"};, printf("%s", code[1]);, return 0;, }, , A) IN, B) USA, C) K, D) Compiler error, Answer [=], , B, Explanation:, Here, we have not used pointers to strings. So a total of 3x4=12 bytes, is allocated. Using a pointers to strings, we can allocate just 3+4+2=9, bytes. Extra byte stores NULL or \0. USA+null = 4 characters.
Page 154 :
18) What is the output of C program with array of pointers to, strings.?, int main(), {, char *code[2];, code[0]= (char *)malloc(4);, strcpy(code[0], "IND");, printf("%s", code[0]);, return 0;, }, , A) I, B) IN, C) IND, D) Compiler error, Answer [=], , C, Explanation:, If you use a pointer to string instead of char str[], you should use, malloc() or calloc() to allocate memory and then write some data like, "IND" into it. Otherwise, your output will be unexpected., 19) What is actually passed to PRINTF or SCANF functions.?, A) Value of String, B) Address of String, C) End address of String, D) Integer equivalent value of String, Answer [=], , B, Explanation:, printf("Hello") takes the address of "Hello" and processes till it reaches, NULL or \0., 20) What is the output of C program with strings.?, int main(), {, char *code="JUMPER";, if(code[6]=='\o'), {, printf("SUMMER");
Page 155 :
}, else, {, printf("WINTER");, }, return 0;, }, , A) SUMMER, B) WINTER, C) Compiler error, D) None of the above, Answer [=], , B, Explanation:, SLASH O is different from SLASH ZERO. Use '\0' to get end of string., , STRUCTURE & POINTERS, SET-1, 1) What is a structure in C language.?, A) A structure is a collection of elements that can be of same data type., B) A structure is a collection of elements that can be of different data type., C) Elements of a structure are called members., D) All the above, Answer [=], , D, Explanation:, struct insurance, {, int age;, char name[20];, }, , 2) What is the size of a C structure.?, A) C structure is always 128 bytes., B) Size of C structure is the total bytes of all elements of structure., C) Size of C structure is the size of largest element., D) None of the above, Answer [=]
Page 156 :
B, Explanation:, Individually calculate the sizes of each member of a structure and make a total to get Full size of a, structure., , 3) What is the output of C program with structures.?, int main(), {, structure hotel, {, int items;, char name[10];, }a;, strcpy(a.name, "TAJ");, a.items=10;, printf("%s", a.name);, return 0;, }, A) TAJ, B) Empty string, C) Compiler error, D) None of the above, Answer [=], , C, Explanation:, Keyword used to declare a structure is STRUCT not structURE in lowercase i.e struct., , 4) What is the output of C program.?, int main(), {, struct book, {, int pages;, char name[10];, }a;, a.pages=10;, strcpy(a.name,"Cbasics");, printf("%s=%d", a.name,a.pages);, return 0;
Page 157 :
}, A) empty string=10, B) C=basics, C) Cbasics=10, D) Compiler error, Answer [=], , C, Explanation:, pages and name are structure members. a is a structure variable. To refer structure members use a DOT, operator say a.name., , 5) Choose a correct statement about C structures., A) Structure elements can be initialized at the time of declaration., B) Structure members can not be initialized at the time of declaration, C) Only integer members of structure can be initialized at the time of declaraion, D) None of the above, Answer [=], , B, Explanation:, struct book, {, int SNO=10; //not allowed, };, , 6) Choose a correct statement about C structure.?, int main(), {, struct ship, {, , };, return 0;, }, A) It is wrong to define an empty structure, B) Member variables can be added to a structure even after its first definition., C) There is no use of defining an empty structure, D) None of the above, Answer [=], , C, , 7) What is the output of C program.?, int main(), {
Page 159 :
B) RED YELLOW, C) YELLOW YELLOW, D) Compiler error, Answer [=], , A, Explanation:, boat2=boat1 copies only values to boat2 memory locations. So changing boat2 color does not change boat1, color., , 9) What is the output of C program with structures.?, int main(), {, struct tree, {, int h;, }, struct tree tree1;, tree1.h=10;, printf("Height=%d",tree1.h);, return 0;, }, A) Height=0, B) Height=10, C) Height=, D) Compiler error, Answer [=], , B, Explanation:, Notice a missing semicolon at the end of structure definition., struct tree, {, int h;, };, , 10) Choose a correct statement about C structure elements.?, A) Structure elements are stored on random free memory locations, B) structure elements are stored in register memory locations, C) structure elements are stored in contiguous memory locations, D) None of the above., Answer [=], , C, , 11) A C Structure or User defined data type is also called.?
Page 160 :
A) Derived data type, B) Secondary data type, C) Aggregate data type, D) All the above, Answer [=], , D, , 12) What are the uses of C Structures.?, A) structure is used to implement Linked Lists, Stack and Queue data structures, B) Structures are used in Operating System functionality like Display and Input taking., C) Structure are used to exchange information with peripherals of PC, D) All the above, Answer [=], , D, , 13) What is the output of C program with structures.?, int main(), {, struct tree, {, int h;, int w;, };, struct tree tree1={10};, printf("%d ",tree1.w);, printf("%d",tree1.h);, return 0;, }, A) 0 0, B) 10 0, C) 0 10, D) 10 10, Answer [=], , C, Explanation:, struct tree tree1={10};, Assigns the value to corresponding member. Remaining are set to Zero. So w is zero., , 14) What is the output of C program with structures.?, int main(), {
Page 162 :
B) IBM, C) Compiler error, D) None of the above, Answer [=], , A, Explanation:, You can initialize structure members at the time of creation of Structure variables., , 16) What is the output of C program with structures pointers.?, int main(), {, struct forest, {, int trees;, int animals;, }F1,*F2;, F1.trees=1000;, F1.animals=20;, F2=&F1;, printf("%d ",F2.animals);, return 0;, }, A) 0, B) 20, C) Compiler error, D) None of the above, Answer [=], , C, Explanation:, F2.animal is not allowed as F2 is a pointer to structure variable. So use ARROW operators. F2->animal., , 17) What, int main(), {, struct bus, {, int seats;, }F1, *F2;, F1.seats=20;, F2=&F1;
Page 163 :
F2->seats=15;, printf("%d ",F1.seats);, return 0;, }, A) 15, B) 20, C) 0, D) Compiler error, Answer [=], , A, Explanation:, DOT operator is used with a structure variable. ARROW operator is used with a pointer to structure, variable., , 18) What is the output of C program with structure arrays.?, int main(), {, struct pens, {, int color;, }p1[2];, struct pens p2[3];, p1[0].color=5;, p1[1].color=9;, printf("%d ",p1[0].color);, printf("%d",p1[1].color);, return 0;, }, A) 5 5, B) 5 9, C) 9 5, D) Compiler error, Answer [=], , B, Explanation:, You can declare and use structure variable arrays., , 19) What is the output of C program with structure array, pointers.?, int main(), {
Page 164 :
struct car, {, int km;, }*p1[2];, struct car c1={1234};, p1[0]=&c1;, printf("%d ",p1[0]->km);, return 0;, }, A) 0, B) 1, C) 1234, D) Compiler error, Answer [=], , C, Explanation:, It is allowed to create array of pointers to structure variables., , 20) Choose a correct statement about C structures., A) A structure can contain same structure type member., B) A structure size is limited by only physical memory of that PC., C) You can define an unlimited number of members inside a structure., D) All the above., Answer [=], , D, , SET-2, 1) What is the output of c program with structures.?, int main(), {, struct car, {int color;};, struct garage, {, struct car mycar[10];, }gar;, struct car c1={5};, gar.mycar[0]=c1;
Page 165 :
printf("%d",gar.mycar[0]);, return 0;, }, , A) NULL, B) 0, C) 5, D) Compiler error, Answer [=], , C, Explanation:, It is an example of nested structures., 2) What is the size of the below C structure in TurboC?, int main(), {, struct books{, int pages;, char str[4];, }b;, printf("%d",sizeof(b));, return 0;, }, , A) 5, B) 6, C) 7, D) 8, Answer [=], , B, Explanation:, 2+4= 6 bytes., 3) What is the output of C program with Structure pointer in, TurboC.?, int main(), {, struct books{, int pages;
Page 166 :
char str[4];, }*ptr;, printf("%d",sizeof(ptr));, return 0;, }, , A) 2, B) 6, C) 7, D) 8, Answer [=], , B, Explanation:, Memory reserved will be the size of sum of individual elements., 4) In a nested structure definition, with country.state.district, statement, memeber state is actually present in the structure.?, (COUNTY, STATE, DISTRICT structures), A) district, B) state, C) country, D) None of the above, Answer [=], , C, 5) What is actually passed if you pass a structure variable to a, function.?, A) Copy of structure variable, B) Reference of structure variable, C) Starting address of structure variable, D) Ending address of structure variable, Answer [=], , A, Explanation:, Yes. If you pass a structure variable by value without & operator, only a, copy of the variable is passed. So changes made within that function do, not reflect in the original variable., 6) What is the output of C program with structures.?, void show(int,int);, int main(), {
Page 167 :
struct paint{, int type;, int color;, }p;, p.type=1;, p.color=5;, show(p.type,p.color);, return 0;, }, void show(int a,int b), {, printf("%d %d",a,b);, }, , A) 1 1, B) 1 5, C) 5 1, D) Compiler error, Answer [=], , B, 7) What is the output of C program with structures.?, int main(), {, struct paint{, int type;, int color;, }p1, p2;, p1.type=1;, p1.color=5;, if(sizeof(p1)==sizeof(p2)), {, printf("SAME");, }, else, {
Page 168 :
printf("DIFFERENT");, }, return 0;, }, , A) SAME, B) DIFFERENT, C) Compiler error, D) None of the above, Answer [=], , A, Explanation:, Yes. Before and after initialization, size of a structure variable does not, change., , 8) Choose a correct statement about C structures., A) A structure enables display of folder structure in OS., B) A structure enables erasing contents in a folder in OS., C) A structure enables to detect and respond to mouse clicks., D) All the above, Answer [=], , D, 9) Choose a correct statement about structure and array.?, A) An array stores only elements of same type. Accessing elements is easy., B) A structure is preferred when different type elements are to be combined as a, single entity., C) An array implementation has performance improvements to structure, D) All the above, Answer [=], , D, 10) What are the types of data allowed inside a structure.?, A) int, float, double, long double, B) char, enum, union, C) pointers and Same structure type members, D) All the above, Answer [=], , D
Page 169 :
Console I/O and Formatted I/O, 1) What is an Escape Sequence in C language.?, A) An escape sequence is a combination of two characters starting with Back, Slash always., B) An escape sequence is usually part of a string to tell compiler to produce New, Lines, New tabs, Single or Double quotes etc, C) An escape sequence is used to format the output to look in desired way., D) All the above, Answer [=], , D, Explanation:, eg. \n outputs new line. \t outputs tab i.e 4 or 8 white spaces., 2) Choose a correct statement about C Escape Sequences., A) \n produces new line., B) \t produces one tab space (white spaces), C) \b produces one Backspace, D) All the above, Answer [=], , D, 3) Choose a correct statement about C Escape Sequences., A) \r produces one Carriage Return. \r does not take you to the next line. It takes, cursor to only the beginning of same line., B) \f produces form feed, C) \a produces Alert Sound or Beep Sound from PC motherboard speaker, D) All the above, Answer [=], , D, 4) Choose a correct statement about C Escape Sequences., A) \' outputs one Single Quote. Right Single Quote., B) \" outputs one Double Quote., C) \\ produces one Visible Back Slash \., D) All the above, Answer [=], , D, 5) What is a format specifier in C language.?, A) A format Specifier tells compiler to treat a variable value is predefined way., B) Different format specifiers are used to print different type of data.
Page 170 :
C) Format specifiers are used to write data to files in a formatted way., D) All the above, Answer [=], , D, 6) Choose a valid C format specifier.?, A) %d prints integer constants, B) %u prints unsigned integer constants, C) %ld prints signed long and %lu prints unsigned long constants, D) All the above, Answer [=], , D, 7) Choose a correct statement about C format Specifiers., A) %c prints unsigned or signed character constants., B) %s prints string constants, C) %l or %L prints long constants., D) All the above, Answer [=], , D, , 8) Choose a correct statement about format specifiers., A) %f prints float constants with 6 digits of precision, B) %lf prints double constants, C) %Lf prints long double constants, D) All the above, Answer [=], , D, 9) What does C format specifier %W.D represent.?, A) W represents total number of columns including precision digits., B) D represents number of precision digits out of W columns., C) Plus(+) before W.D is for Right Alignment. Minus(-) before W.D is for Left, Alignment, D) All the above, Answer [=], , D, 10) Choose a C Formatted Input Output function below., A) printf(), scanf(), B) sprintf(), sscanf(), C) fprintf(), fscanf()
Page 171 :
D) All the above, Answer [=], , D, 11) Choose a C unformatted input output function below., A) gets(), puts(), B) getchar(), putchar(), C) A & B, D) None of the above, Answer [=], , C, 12) What is the output of C program.?, int main(), {, int a=123;, printf("*%06d*",a);, return 0;, }, , A) *123*, B) *6123*, C) *000123*, D) *006123*, Answer [=], , C, Explanation:, %6d reservers 6 columns. %Zero6d causes Remaining columns will be, filled with Zero., 13) What is the output of C program.?, int main(), {, int a=123456;, printf("*%03d*",a);, return 0;, }, , A) *123*, B) *6123*, C) *123456*
Page 172 :
D) *012345*, Answer [=], , C, Explanation:, %3d reserves three columns. But 123456 is more than 3 columns. So, width 3 will be ignored., 14) What is the output of C program.?, int main(), {, int a=6543;, printf("*%5d,*%-5d*",a,a);, return 0;, }, , A), *56543,*56543*, , B), * 6543,*6543 *, , C), *6543 ,* 6543*, , D), *6543,*6543*, Answer [=], , B, Explanation:, %5d reserves 5 columns. 6543 is aligned right. So One Space is filled in, the first column. %-5d aligns 6543 left. So right side one Space is filled, as 6543 is only a 4 digit number., , 15) What is the output of C program.?, int main(), {
Page 173 :
float a=654.123456f;, printf("%3.3f,%3.2f",a,a);, return 0;, }, , A) 654,654, B) 654.123456,654.123456, C) 654.123,654.12, D) 654.000,654.00, Answer [=], , C, Explanation:, %3.3 reserves 3 columns. But the 654.123456 is a 9 column number., So only .3 will be treated as important to print 3 digit precision number., .2 prints number with 2 digit precision., 16) What is the output of C program.?, int main(), {, char str[]="123";, printf("*%4s*%-4s*",str,str);, return 0;, }, , A) *4123*4123*, B) * 123*123 *, C) *123 * 123*, D) *123*123*, Answer [=], , B, Explanation:, %4s reserves 4 columns. If the string length is less you can see spaces, on the left side. %-4s also reserves 4 columns but aligns content on the, right side., 17) Choose a correct statement about sprintf and sscanf, functions.?, char str[20];, , A) sprintf(str,"formatstring",variables) prints output to console., sscanf(str,"formatstring",&variables) scans keyboard input and copies to str.
Page 174 :
B) sprintf(str,"formatstring",variables) prints output to string str., sscanf(str,"formatstring",&variables) scans keyboard input and prints to console, C) sprintf(str,"formatstring",variables) prints output to string str., sscanf(str,"formatstring",&variables) scans input from str itself and assigns data, to &variables., D) None of the above, Answer [=], , C, Explanation:, Both functions SSCANF or SPRINTF avoid getting input from keyboard, or displaying on Console / Screen., 18) What is the output of C program.?, int main(), {, char ch='A';, ch=getchar();, putchar(ch);, return 0;, }//input= S, , A) A, B) B, C) S, D) Compiler error, Answer [=], , C, Explanation:, getchar() reads one character from keyboard. putchar(ch) prints one, character., 19) Choose a correct C statement.?, A) SCANF can accept all types of data from keyboard including numbers and, strings, B) GETS can accept only one String of any length and any number of words., GETCHAR can accept only one character constant from keyboard., C) SCANF can accept only single word Strings, D) All the above, Answer [=], , D, 20) What is the output of c program with %* operator.?
Page 175 :
int main(), {, char kh;, scanf("%*c %c",&kh);, putchar(kh);, return 0;, }//input=G H, , A) G, B) H, C) A, D) Compiler error, Answer [=], , B, Explanation:, %* ignores the entered argument. So here G is ignored. 2nd argument,, H is accepted by variable kh. Remember, You have to enter all, arguments corresponding to ea, , C PREPROCESSOR DIRECTIVES, SET-1, 1) What are the types of C Preprocessor Directives.?, A) Macros, B) Conditional Compilation, C) File Inclusion, D) All the above, Answer [=], , D, , 2) Processor Directive in C language starts with.?, A) $ symbol (DOLLAR), B) @ symbol (At The Rate), C) & symbol (Ampersand), D) # symbol (HASH), Answer [=], , D, Explanation:, eg. #include<stdio.h>, , 3) Preprocessor in C language works on.?, A) DOTC file (.c)
Page 176 :
B) DOTEXE file (.exe), C) DOTH file (.h), D) DOTCP file (.cp), Answer [=], , A, Explanation:, .C file is also called Source Code file., , 4) What is the another name for .C file.?, A) Executable code, B) Source Code, C) Distributable Code, D) Macro code, Answer [=], , B, , 5) What is the keyword used to define a C macro.?, A) def, B) definition, C) define, D) defy, Answer [=], , C, Explanation:, #define PI 3.1428, , 6) What is the output of C program with #define.?, #define CVV 156, int main(), {, int a=10;, a = a*CVV;, printf("CVV=%d",a);, return 0;, }, A) 0, B) 1560, C) 1560, D) Compiler error, Answer [=], , C, Explanation:, During expansion of source code, a=a*CVV is replaced with a=a*156. #define is used to declare global, constants., , 7) What is the C keyword used to create global Constants.?, A) constant, B) definition, C) def
Page 177 :
D) define, Answer [=], , D, Explanation:, #define KM 1.6, , 8) Choose a correct C statement about #define statement.?, #define CVV 156, A) CVV is called Macro Expansion. 156 is called Macro Template., B) CVV is called Macro Expansion. 156 is also called Macro Expansion., C) CVV is called Macro Template. 156 is called Macro Expansion., D) None of the above, Answer [=], , C, , 9) What is the output file generated after processing a .C file.?, A) .h file, B) .exe file, C) .cp file, D) .bak file, Answer [=], , B, Explanation:, Yes. C program is converted to an executable file for distribution to outside world instead of sharing your, original source code which may be copy righted logic., , 10) How do you safeguard your .C file code from copying by outside, developers or world.?, A) Encrypt a C file and share, B) Obfuscate a C file and share, C) Scramble a C file and share, D) Convert to Exe and share., Answer [=], , D, , 11) What is the output of C program with macros.?, #define ERRMSG printf("Some error.");, int main(), {, printf("JAR.");, ERRMSG;, return 0;, }, A) JAR.
Page 178 :
B) JAR.ERRMSG, C) JAR.Some error., D) Compiler error, Answer [=], , C, Explanation:, In place of ERRMSG corresponding macro expansion is substituted blindly., , 12) What is the output of C program with macros.?, #define ERRMSG(a) printf("Error=%d",a);, int main(), {, ERRMSG(10);, return 0;, }, A) ERRMSG(10), B) Error=, C) Error=10, D) Compiler error, Answer [=], , C, Explanation:, Inside main the statment printf("Error=%d",10) is substituted., printf("Error=%d",10);, , 13) What is the output of C program.?, #define LOGIC(a,b) (a==b), int main(), {, if(LOGIC(5,5)), {, printf("SAME ");, }, return 0;, }, A) SAME, B) LOGIC(5,5), C) 5==5, D) Compiler error, Answer [=], , A, Explanation:
Page 179 :
LOGIC(5,5) is replaced by (5==5) with outer paranthesis., , 14) How do you separate a multiline macro in C language.?, A) Using * operator, B) Using % operator, C) Using \ operator, D) Using + operator, Answer [=], , C, Explanation:, #define LOOP(a) while(a>0) \, {printf("%d ",a);}, , 15) What is the output of C program.?, #define LOOP(a) for(int i=1;i<=a;i++) \, {printf("%d ",i);}, int main(), {, LOOP(5);, return 0;, }, A) 5, B) 5 5 5 5 5, C) 1 2 3 4 5, D) Compiler error, Answer [=], , D, Explanation:, 5 in LOOP(5) will be a condition for the FOR loop starting from i=1., , 16) What is the output of C program.?, #define TANK(a) a*10+2, int main(), {, int a = TANK(2)*2;, printf("%d",a);, return 0;, }, A) 44
Page 180 :
B) 22, C) 24, D) Compiler error, Answer [=], , C, Explanation:, TANK(2)*2 is replaced by 2*20+2*2. It gives only 24. Remember, you should have put (a*10+2), paranthesis TANK definition to get expected results., , 17) What is the file extension of expanded source code of .C file, after preprocessing.?, A) .e file, B) .h file, C) .l file, D) .p file, Answer [=], , C, Explanation:, def.c is converted into def.l file., , 18) What is the command to preprocess a C file manually.?, A) pp abc.c, B) cpp abc.c, C) exp abc.c, D) op abc.c, Answer [=], , B, Explanation:, cpp refers to C Pre Processor., cpp abc.c, , 19) Choose a correct statement about C Macro.?, A) Macro template(eg. PI or function) will be replaced by Macro Expansion(3.1428) as many number of times as, it appears in the C program increasing Source Code size in bytes., B) Macros increase program speed when compared to functions., C) Functions use less memory as the program code is written and placed only one place in source code. Macros, put function code everywhere it is called again and again., D) All the above, Answer [=], , D, , 20) What is the C Preprocessor directive to be used to add a, header file or any file to existing C program.?, A) #add, B) #present, C) #include, D) $include, Answer [=], , C, Explanation:, #include<stdio.h>
Page 181 :
SET-2, 1) What does #include stdio.h does in c language.?, A) It includes stdio.h into existing C program., B) #include increases the size of C program by including the specified file contents like functions, constants etc., C) #include includes specified file before compilation., D) All the above, Answer [=], , D, , 2) What is the abbreviation of C STDIO in stdio.h.?, A) Standard Input Output, B) String Terminating Operations Input Output, C) Store Input Output, D) None of the above, Answer [=], , A, , 3) Choose a correct statement about #include<stdio.h>.?, A) A file named stdio.h will be searched in all directories and included if found, B) A file named stdio.h will be searched in current directory and included if found, C) A file named stdio.h will be searched in current directory and pre configured list of directories in search path, and included if found, D) None of the above, Answer [=], , B, Explanation:, Only current directory will be searched for the specified file, , 4) Choose a correct C statement about #include", A) A file named stdio.h will be searched in all directories and included if found, B) A file named stdio.h will be searched in current directory and included if found, C) A file named stdio.h will be searched in current directory and pre configured list of directories in search path, and included if found, D) None of the above, Answer [=], , C, Explanation:, Current Directory + Search Path Directories, , 5) In Turbo C, Search Path of Directories for #Include is, mentioned under the option.?, A) Include Directories, B) Exclude Directories, C) Add Directories, D) Extra Directories, Answer [=], , A, Explanation:, You can specify multiple directories separated by Semicolons(;) under search path as below., C:\turboc;C:\abc\libs;C:\def\bc\docs;
Page 183 :
#endif, Answer [=], , D, Explanation:, C Conditional Compilation Commands IFDEF, ELSE and ENDIF should be in lower case letters only. If, macroname exists or is defined, it is treated as true and TRUE block (IF) is executed. Otherwise, FALSE, block (ELSE) is executed., , 7) What is the output of C program with conditional compilation, commands.?, #define CVV 156, int main(), {, #ifdef CVV, printf("CVV YES");, #else, printf("CVV NO");, #endif, return 0;, }, A) 156, B) printf("CVV YES");, C) CVV YES, D) CVV NO, Answer [=], , C, Explanation:, Macro CVV is already defined., , 8) What is the output of C program with conditional compilation, commands.?, #define CVV 156, int main(), {, #ifdef cvv, printf("CVV YES");, #else
Page 186 :
#ifdef CVV, #define CVV 199, #elif PVV, printf("Inside ELIF");, #else, printf("Inside ELSE");, #endif, return 0;, }, A) Inside ELIF, B) Inside ELSE, C) No output, D) Compiler error, Answer [=], , B, Explanation:, #ELIF is similar to ELSE IF condition., , 13) What is the output of C program with #undef.?, #define BIRD 5, int main(), {, #ifdef BIRD, printf("BIRD=5.");, #else, printf("UNKNOWN.");, #endif, #undef BIRD, #define BIRD 10, printf("BIRD=%d",BIRD);, return 0;, }, A) BIRD=5.BIRD=5, B) BIRD=10.BIRD=10, C) BIRD=5.BIRD=10, D) Compiler error, Answer [=], , C, Explanation:
Page 187 :
Yes. You can use #define any where. Using #undef removes the definition of existing macro. No compiler, error if macro is not found., , 14) What is the output of C program with #undef.?, int main(), {, #undef BIRD, printf("OKAY");, return 0;, }, A) OKAY, B) Compiler error, C) BIRDOKAY, D) None of the above, Answer [=], , A, Explanation:, Macro BIRD is not define. So #undef tries to remove definition if any. No compiler error will come., , 15) What is a Pragma in C language.?, A) A Pragma may be an instruction to build tool to process or generate comments, B) A Pragma may be an instruction to compiler to execute specific functions at specific times say startup or exit, of program., C) A pragma may be an instruction to tell compiler to ignore certain warnings., D) All the above, Answer [=], , D, Explanation:, #pragma starup myfunction1, #pragma exit myfunction2, #pragma warn-rvl, , 16) What is the C Pragma directive or command to execute a, particular function at startup of program.?, A) #pragma start function1, B) #pragma statup function1, C) #pragma startnow function1, D) #prama startup function1, Answer [=], , B, , 17) What is the output of C program with Pragma.?, void show1();, void show2();
Page 188 :
#pragma startup show1, #pragma exit show2, int main(), {, printf("MAIN.");, }, void show1(), {, printf("START.");, }, void show2(), {, printf("END.");, }, A) MAIN.START.END., B) START.MAIN.END, C) START.END.MAIN, D) END.START.MAIN, Answer [=], , B, , 18) At what stage of building a C program does Pragma work.?, A) Before Compilation, B) After compilation, C) After Linking, D) None of the above, Answer [=], , A, Explanation:, A Pragma works before compilation and after Preprocessing. It tells compiler to follow or ignore certain, things., , 19) Choose a correct implementation of C Pragma Warning.?, A) #pragma warn -par, B) #pragma warn -rch, C) #pragma warn -rvl, D) All the above, Answer [=], , D, Explanation:, RVL - Return Value missing. PAR - Parameter not used. RCH - Code not reachable., , 20) Choose a correct statement about C Macro.?, A) A Macro name can be in lower or upper case.
Page 189 :
B) A Macro can be nested. It can use another macro as part of its implementation. #define CVV 2*OLDCVV., Here OLDCVV is another macro defined prior to Macro CVV., C) Control is not passed to Macro as it is like just a dummy String(eg. CVV) Replacement technique with, implementation (Macro Expansion part), D) All the above, Answer [=], , D, , C Program Build Process, 1) What is the input file in a C program building process.?, A) filename.k, B) filename.cpp, C) filename.c, D) filename.p, Answer [=], , C, Explanation:, Obviously, it is a C file with some code., 2) What is the output Filename of C Program build process.?, A) filename.ex, B) filename.bak, C) filename.exe, D) filename.asm, Answer [=], , C, Explanation:, Yes. One Exe file with the same name as .C file will be created., 3) What is the first step in C program building process.?, A) Compiling, B) Assembling, C) Linking, D) Preprocessing, Answer [=], , D, Explanation:, Preprocessing deals with #define macros, #pragma, #include and other, commands., 4) What is the next step to Preprocessing in C Program build, process.?, A) Compiling
Page 190 :
B) Assembling, C) Linking, D) None of the above, Answer [=], , A, 5) What is the next step to Compiling in C program build process.?, A) Preprocessing, B) Assembling, C) Linking, D) None of the above, Answer [=], , B, Explanation:, An assembler converts Assembly code from compiler and converts it to, Object code or machine code., 6) What is the next step to Assembling in C program build, process.?, A) Preprocessing, B) Compiling, C) Linking, D) None of the above, Answer [=], , C, Explanation:, Linking combines our C file object code and predefined library functions, object code into a single exe file., 7) What is a C Editor.?, A) A C compiler, B) A C assembler, C) A C code editor like notepad, D) None of the above, Answer [=], , C, Explanation:, You can any editor for typing and editing C code., , 8) What is the output of C Compiler compiling.?, A) An assembly language code
Page 191 :
B) Object Code, C) Class file code, D) None of the above, Answer [=], , A, 9) Expanded Source code is the output of which C program building, process.?, A) Preprocessor, B) Assembler, C) Linker, D) Compiler, Answer [=], , A, Explanation:, Source code is expanded with suitably replacing Macro Names (eg. CVV, or PI) with Values or Expressions (eg. 3.14 or 2*x+y)., 10) Choose a correct statement about C program output file.?, A) Output file .exe is machine dependent. .Exe is windows suitable file., B) Exe file does not work in Linux or Unix machines. So different type of output is, created on different machines, C) Linker produces a suitable output file for each maching, D) All the above, Answer [=], , D, , File Operations I/O, 1) What is the need for a File when you can store anything in, memory.?, A) Memory (RAM) is limited in any computer., B) A file is stored on Hard Disk which can store Gigabytes of data., C) File stored on Hard Disk is safe even if PC is switched off. But Memory or RAM contents are cleared when, PC is off., D) All the above, Answer [=], , D, , 2) What is the keyword used to declare a C file pointer.?, A) file, B) FILE, C) FILEFP, D) filefp
Page 192 :
Answer [=], , B, Explanation:, FILE *fp;, , 3) What is a C FILE data type.?, A) FILE is like a Structure only, B) FILE is like a Union only, C) FILE is like a user define int data type, D) None of the above, Answer [=], , A, Explanation:, Yes. FILE type pointer eg. FILE *fp holds an address of a C Structure that can store type of file, operation, memory location of current read and next read and other useful information., , 4) Where is a file temporarily stored before read or write, operation in C language.?, A) Notepad, B) RAM, C) Hard disk, D) Buffer, Answer [=], , D, Explanation:, Yes. A Buffer is like an empty bucket that is filled with information so that direct read write operation on, hard disk is avoided for better performance., , 5) Choose a correct statement about C file operation program.?, int main(), {, FILE *fp;, char ch;, fp=fopen("readme.txt","r");, while((ch=fgetc(fp)) != EOF), {, printf("%c",ch);, }, }, A) FOPEN opens a file named readme.txt in Read Mode ("r)., B) EOF is End Of File. ch==EOF checks for end of file and while loop stops or exits., C) FGETC(fp) is a function that returns one character and cursor goes to next character., D) All the above, Answer [=], , D, Explanation:
Page 193 :
Inside while loop, we have not done any increment operations like i++. Because fget() function takes care, of returning one by one character from file., , 6) What is the need for closing a file in C language.?, A) fclose(fp) closes a file to release the memory used in opening a file., B) Closing a file clears Buffer contents from RAM or memory., C) Unclosed files occupy memory and PC hangs when on low memory., D) All the above, Answer [=], , D, , 7) If a FILE pointer is NULL what does it mean.?, FILE *fp;, fp=fopen("abc.txt","w");, A) Unable to open a file named abc.txt, B) abc.txt is not available on disk, C) Hard disk has hard ware problems., D) All the above, Answer [=], , D, , 8) Choose a correct statement about FGETS in C program.?, int main(), {, FILE *fp;, char str[80];, fp=fopen("readme.txt","r");, while(fgets(str,80,fp) != NULL), {, printf("%s",str);, }, fclose(fp);, }, A) str in fgets() is a like a user buffer that can store 80 characters each time, B) FGETS returns null if no characters are left, C) fgets() reads content from File. FPUS writes content back to File., D) All the above, Answer [=], , D, Explanation:, Here "r" is File open mode. eg. "w" is used for writing a file.
Page 194 :
9) Choose a correct statement about C file "R" mode operation, using fopen., fopen("abc.txt","r");, A) If the file abc.txt is found, fopen returns a FILE pointer., B) If the file abc.txt is not found, fopen returns NULL or 0., C) File abc.txt is only opened in Read Mode. Now write operation is performed., D) All the above, Answer [=], , D, , 10) Choose a correct statement about File Write Mode "w"., File *fp;, fp=fopen("abc.txt","w");, A) If the file abc.txt is not found File abc.txt is created on disk., B) If the file abc.txt is found, fopen() returns a FILE pointer as usual. Every time, contents of abt.txt are, overwritten in "w" mode., C) Read operation is not allowed in "w" mode., D) All the above, Answer [=], , D, Explanation:, All the above, , 11) Choose a correct statement about C File Mode "w+"., FILE *p;, p=fopen("abc.txt","r+");, A) r+ mode allows reading of existing contents of file abc.txt only if file is found., B) If file is not found, NULL is returned by fopen()., C) You can read existing contents, edit existing content and add new content., D) All the above, Answer [=], , D, , 12) Choose a correct statement about C file mode "w+"., FILE *fp;, fp=fopen("abc.txt","w+");, A) Like "w" mode, "w+" mode creates a new file abc.txt if not found. NULL is only returned if some other, problems in PC exist in opening a file., B) w+ mode allows you to read the file also. Only after writing, you can read contents if any written. Before, writing existing contents are emptied., C) w+ mode always makes a file contents empty like w mode., D) All the above, Answer [=], , D
Page 195 :
13) Choose a correct statement about C file mode "a"., FILE *fp;, fp=fopen("abc.txt","a");, A) "a" is for append operation. You can append or add new content to the existing contents., B) If file is not found, new file is created., C) You can not write read file contents., D) All the above, Answer [=], , D, , 14) Choose a correct statement about C file mode "a+"., FILE *fp;, fp=fopen("abc.txt","a+);, A) a+ mode always appends new data to the end of existing content, B) a+ mode creates a new file if not found or existing., C) a+ mode allows reading also. mode "a" allows only appending not reading., D) All the above, Answer [=], , D, , 15) Choose a correct statement about opening a file in binary mode, for reading., FILE *fp;, fp=fopen("abc.txt","rb");, A) rb mode opens the file in binary mode, B) Binary mode is just reading or writing in bytes instead of integers, characters or strings., C) Binary mode saves memory occupied by contents., D) All the above, Answer [=], , D, , 16) What is the syntax for writing a file in C using binary mode.?, FILE *fp;, A), fp=fopen("abc.txt","wr");, B), fp=fopen("abc.txt","wb");, C)