Programming with C/Advance Programming in C

(1 mark each)


1. Which of the following language is predecessor to C Programming Language? 

            a) A    

            b) B   

            c)   BCPL                  

            d)   C++ 


2. C programming language was developed by :

            a) Dennis Ritchie      

            b)   Ken Thompson 

            c) Bill Gates                                                                                                    

            d) Peter Norton 


3. C was developed in the year ___ 

            a) 1970          

            b) 1972          

            c) 1976           

            d)   1980 


4. C is a ___ language 

            a) High Level

            b) Low Level            

            c) Middle Level       

            d) Machine Level 


5. C language is available for which of the following Operating Systems? 

            a) DOS            



            d) All of these 



6. Which of the following symbol is used to denote a pre-processor statement? 

            a) !      

            b)   #   

            c)   ~   

            d) ; 


7. Which of the following is a Scalar Data type 

            a) Float          

            b) Union            

            c) Array    

            d) Pointer 


8. Which of the following are tokens in C? 

            a) Keywords 

            b) Variables   

            c) Constants       

            d) All of the above 


9. What is the valid range of numbers for int type of data? 

            a) 0 to 256      

            b)   -32768 to +32767      

            c) -65536 to +65536

            d) No specific range


10. Which symbol is used as a statement terminator in C? 

            a) !      

            b)   #   

            c)   ~   

            d) ; 


11. Which escape character can be used to begin a new line in C? 

            a) \a   

            b) \b    

            c)   \m

            d) \n 



12. Which escape character can be used to beep from speaker in C? 

            a) \a    

            b)   \b  

            c) \m  

            d) \n 



13. Character constants should be enclosed between ___ 

            a) Single quotes         

            b)   Double quotes      

            c) Both a and b         

            d) None of these 



14. String constants should be enclosed between ___ 

            a) Single quotes         

            b) Double quotes      

            c) Both a and b         

            d) None of these 




15. Which of the following is invalid? 

            a) ‘’     

            b)   “ “

            c) ‘a’  

            d)   ‘abc’ 



16. The maximum length of a variable in C is ___ 

            a) 8     

            b) 16  

            c)   32 

            d)   64 



17. What will be the maximum size of a float variable? 

            a) 1 byte         

            b)   2 bytes     

            c)   4 bytes     

            d) 8 bytes 



18. What will be the maximum size of a double variable? 

            a) 1 byte         

            b)   4 bytes     

            c)   8 bytes     

            d) 16 bytes 



19. A declaration float a,b; occupies ___ of memory 

            a) 1 byte            

            b) 4 bytes       

            c)   8 bytes     

            d)   16 bytes 



20. The size of a String variable is 

            a) 1 byte         

            b)   8 bytes     

            c)   16 bytes    

            d)   None of these 



21. Which of the following is an example of compounded assignment statement? 

            a) a = 5           

            b)   a += 5      

            c)   a = b = c   

            d)   a = b 



22. The operator && is an example for ___ operator.  

            a) Assignment

            b)   Increment

            c) Logical      

            d)   Rational 



23. The operator & is used for 

            a) Bitwise AND         

            b) Bitwise OR           

            c) Logical AND        

            d)   Logical OR 



24. The operator / can be applied to 

            a) Integer values        

            b)   Float values        

            c) Double values       

            d)   All of these 



25. The equality operator is represented by 


            b) .EQ.          

            c) =    

            d) == 



26. Operators have hierarchy. It is useful to know which operator 

            a) is most important   

            b)   is used first         

            c)   is faster                   

             d) Operates on large numbers 



27. The bitwise AND operator is used for 

            a) Masking    

            b)   Comparison          

            c)   Division    

            d)   Shifting bits 



28. The bitwise OR operator is used to 

            a) Set the desired bits to 1    

            b) Set the desired bits to 0    

            c) Divide numbers       

             d) Multiply numbers 



29. Which of the following operator has the highest precedence? 

            a) *     

            b)   ==

            c)   =>

            d) + 


30. The associatively of! Operator is 

            a) Right to Left         

            b)   Left to Right        

            c)   (a) for Arithmetic and (b) for Relational 

            d)   (a) for Relational and (b) for Arithmetic 



31. Which operator has the lowest priority? 

            a) ++   

            b) %   

            c) +    

            d)   || 



32. Which operator has the highest priority? 

            a) ++  

            b)   %  

            c)   +   

            d)   || 



33. Operators have precedence. A Precedence determines which operator is 

            a) Faster         

            b)   Takes less memory           

            c) Evaluated first     

            d)   Takes no arguments 



34. Integer Division results in 

            a) Rounding the fractional part          

            b) Truncating the fractional part   

             c) Floating value       

            d)   An Error is generated 



35. Which of the following is a ternary operator? 

            a) ?:    

            b)   *   

            c)   sizeof                    

            d)   ^ 



36. What will be the output of the expression 11 ^ 5? 

            a) 5     

            b) 6   

            c) 11   

            d)   None of these 



37. The type cast operator is 

            a) (Type)        

            b)   cast ()       


            d)//   " " 



38. Explicit type conversion is known as 

            a) Casting      

            b)   Conversion           

            c)   Disjunction           

            d)   Separation 



39. The operator + in a+=4 means 

            a) a = a + 4    

            b)   a + 4 = a   

            c)   a = 4                    

            d) a = 4 + 4 



40. p++ executes faster than p+1 because 

            a) p uses registers       

            b)   p++ is a single instruction         

            c) ++ is faster than +   

            d) None of these 



(2 marks each)


41. Which of the following is charecter oriented console I/O function? 

            a) getchar() and putchar()   

            b)   gets() and puts()   

            c) scanf() and printf()  

            d)fgets() and fputs() 



42. All of the above integer type plus the chair are called the………..float and double are called the………….

a)      Integral types, integral types

b)      Float types, integral types

c)      Both of the above

d)     None of the above


43.       The two user defined data types are:

a)      enumerated, constructor

b)     Enumerated, typed

c)      Typedet, deconstructor

d)     None of the above


44.       What are the legal variable names that can be included in C program.

a)      Printf, x1, gama, scanf

b)      Break (), struct, best-yet, result

c)      X1, out-file, gamma, x

d)     Pow, gets, x.1, result


45.       The ……………….variable is not destroyed on exit from the function; instead its value is presented and becomes available again. When the function is next called. These variables are declared as ………………….

a)      extern, localvariable

b)      Static, global variable

c)      Static, local variable

d)     Exten, global variable


46.       An …………..is a collection of variables of the same type. And they are declared like this:

a)      Arry, int height (10)

b)      Structure, struct height

c)      Enumerated, Enum height (2)

d)     Classes, class height





47.       It is divided from a compute language named…………….and from an earlier language………………


a)                  B, BCLP

b)                  B, PCPL

c)                  B, BCPL

d)                 None of the above


48.       Values in C are stored in………………..and ………..are structured by defining and calling functions.


a)                  Variables, process

b)                 Variables, programs

c)                  Structures, program

d)                 Constants, header files


49.       ……………..allows the programs to interact with the screen, keyboard and file system of your computer


a)                  # include (stdio.h>

b)                  #include

c)                  #include

d)                 #include


50.       Curly brackets in C are used to group statements together as in a function, or in the body of a loop. Such a grouping in known as a ……………..a ……………..


a)                  Conditional statement, process

b)                 Compound statement, block

c)                  Looping statement, loop

d)                 None of the above


51        …………….is a library function used in C to display any output to the terminal. The text to be printed is enclosed in…………….quotes.


a)                  Printf, Single

b)                 Printf, double

c)                  Scanf, double

d)                 none


52.       The C programming language was developed at ……………..laboratory by……….during the early…………….


a)      AT and T’S bell lab, Dennis Ritchie, 1970’s

b)      AT and T’S bell lab, lady ada levelace, 1968

c)      Microsoft lab, Berry Bohm, 1965

d)     None of the above


53.       Output of the printf("%-2.3f n",17.23478) will be

a)                  17.23478

b)                 17.235

c)                  17.2348

d)                 17.23

54.       continue statement is used 

a)      to go to the next iteration in a loop      

b)      come out of a loop                                   

c)      exit and return to the main function        

d)     restarts iterations from beginning of loop 


55.       What will be the value of the following :-

1.      floor(5.8)

2.      floor(-5.8)

a)                  -5, -6

b)                 5, -6

c)                  –5, 6

d)                 5, 6


56.       The _________ and ______ operator are used when we want to test more than one condition.(&&, ||)


57.       Suppose that i is an integer variable whose value is 7 and f is floating point variable whose value is 8.5. Evaluate the following expression : ( i + f)%4

a)                  3

b)                  3.5

c)                  4

d)                 Invalid

58.       What would be the value of x after execution of the following statements ?

            int x,y=10;

            char z=’a’;


a)                  Invalid

b)                  17

c)                  107

d)                 10a


59.       There are two ways to categorize variables : By ___________ ,and by __________(data type, storage class)


60.       Strings in C are represented by array of characters. The end of the string is marked with a special character, _________character, which is simply the character with the value 0. Ans it is represented by another character escape sequence, ________(null, \0)




(4 marks each)


61.       Match the following

a)      New line                                        i) 1t

b)      Tab                                                ii) \0

c)      Single quotes                                 iii) \n

d)     Null                                               iv) ‘\”


a)                  a iii, b i, c iv, d ii

b)                  a i, b ii, c i, d i

c)                  a ii, b iii, c ii, d iii

d)                 a iv, b iv, c iii, d iv


62        The string is actually stored as an array of…………….the null character ………is automatically placed at the end of a string to act as a string…………..


a)                  Constants, \n, terminator

b)                 Characters, \0, terminator

c)                  Character, \t, initialize

d)                 None of the above 


63        C program has a separate section called …………..section to declare variables, placed just after the start of any block of code. Declaration in turn does two things:


            1) It tells the name of the variable to the…………….

            2) Just also specifies the type of …………..the variable will hold


a)      Declaration, compiler, data

b)      Declaration, assembler, data

c)      Definition, compiler, variable

d)     None


64        Primary data types are:


a)      Character, typedef, double, float

b)      Chan, hond, typedef, double

c)      Char, int, double, float

d)     All of the above


65        A…………….variable declaration looks normal, but is located outside any of the programs function. This is usually done at the beginning of the program file before the ………..but after…………….directives.



a)      Global, main (), preprocessor

b)      General, main (), Preprocessor

c)      General, main (), headerfile

d)     None of the above


66.       What will be the output of the following.




            int *i, *j, a=12, b=2,c;

            c=(a=a+b, b=a/b, a=a*b, b=a-b);



            a)         93                                           

            b)         92

            c)         91                                           

            d)         90.



67.       The output of the following program:




            int a[3][3]=(3,7,8,6,5,4,3,5);

            printf (“%d”, (a[2][0]>a[0][0])? a[0][2]: a[2][2]);


            a)         8                                             

            b)         7

            c)         6                                             

            d)         None of the above.



68.       Study the following statements:

            i)          Continue statement may also be used in a for loop.

            ii)         Break statement many also be used in if statement.

            Pick out the most correct answer from the following :

            a)         Only statement (i) is correct             

            b)         Only statement (ii) is correct

            c)         Both are correct.                                

            d)         None of these.



69.       Study the foll c program:


            void main()


            int a=7,b=5;



            case 1: a=a-b;

            case 2: a=a+b;

            case 3: a=a*b;

            case 4: a=a/b;

            default :           a=a;




            What will be the output:

            a)         7                                                         

            b)         5

            c)         2                                                         

            d)         None of these.



70.       Study the following C program:


void main()


static a,b;

while (a>b++);


            a)         a=0,b=1                                              

            b)         a=0,b=0

            c)         a=1,b=1                                              

            d)         None of these.



71.       What is the output of:


void main()


int a=0;

for (;a;);



            a)         -1                                                        

            b)         0

c)                  1                                                         

d)         None of these.




72.       Initially C was designed as a system programming long under…………….C has…………, ………….statements and …………….calls to have a control over the program flow.


a)                  PASCAL, Loops, if, function

b)                  UNIX, loops, if, function

c)                  UNIX, structures, if, union

d)                 None of the above


73.       C is ……………language, i.e. it recognizes a …………..case letter and it’s ……….case equivalent as being different.        


a)                  Case sensitive, upper, lower

b)                  Not a case sensitive, upper, lower

c)                  Not a case sensitive, predefined, user defined

d)                 None of the above


74.       An expression contains relational, assign. ment and arithmetic operators. If Parenthesis are not present, the order will be 

a)      Assignment, arithmetic, relational           

b)      Relational, arithmetic, assignment  

c)      c)Assignment, relational, arithmetic        

d)     Arithmetic, relational, assignment 


75.       Match the followings:


A. double acos(double x) --                (i) Compute arc tangent of x.
B. double asin(double x) --                 (ii) Compute arc sine of x.
C. double atan(double x) --                 (iii) Compute arc cosine of x.
D. double atan2(double y, double x) -- (iv) Compute arc tangent of y/x.


a)                  A- (iii), B-(ii), C-(i), D-(iv)

b)                  A- (ii), B-(ii), C-(iii), D-(iv)

c)                  A- (iii), B-(ii), C-(iv), D-(i)

d)                 A- (iii), B-(iv), C-(i), D-(ii)


                                                                                      SAMPLE PAPER = 2


                                                                                         (1 mark each)


1)      A pointer to a pointer in a form of 

a)      multiple indirection    

b)      a chain of pointers      

c)      both a and b              

d)     None of these 

2)      Pointers are of 

a)      integer data type        

b)      character data type                                         

c)      unsigned integer data types 

d)     None of these 


3)      Identify the invalid pointer arithmetic 

a)      Addition of float value to a pointer            

b)      Comparision of pointers that do not point to the element of the same array  

c)      Subtracting an integer from a pointer  

d)     Assigning the value 0 to a pointer variable 

4)      Which is the correct way to declare a pointer?

a)      int_ptr;                                               

b)     int *ptr;

c)      *int ptr;                                  

d)     None of these.



5)      If you want to exchange two rows in a two dimensional array, the fastest way is to:

a)      Exchange the elements of the 2rows

b)      Exchange the address of each element in the two row]

c)      Silence the address of the rows in an array of pointer and exchange the pointer

d)     None of these.

6)      A multidimensional array can be expressed in terms of 

a)      array of pointers rather than as pointers to a group of contiguous array         

b)      array without the group of contiguous array 

c)      data type arrays 

d)     None of these 

7)      Which is the correct way to declare a pointer?

a)      int_ptr;                                               

b)     int *ptr;

c)      *int ptr;                                  

d)     None of these.




8)      If you want to exchange two rows in a two dimensional array, the fastest way is to:

a)      Exchange the elements of the 2rows

b)      Exchange the address of each element in the two row]

c)      Silence the address of the rows in an array of pointer and exchange the pointer

d)     None of these.


9)      Accessing members of a union is via ________ member operator or, for pointers to unions, the _______ operator. (.(dot), ->)



10) Pointer is a variable containing the address of another variable. (True)


11) A function can’t return a pointer to the caller. (False)



12) Null character is represented by 

a)      \n        

b)     \0        

c)      \o        

d)     \e 


13) A Structure 

a)      can be read as a single entity 

b)     cannot be read as a single entity                 

c)      can be displayed as a single entity

d)     has member variables that cannot be read individually 


14) We can not write a function that returns the structure.                (False)


15) ______ is a data structure whose elements can differ in type. (Structure).



16) A _________ is a convenient tool for handling a group of logically related data items. (Structure).


17) #include is called _____________(Preprocessor directive)



18) malloc() function returns a pointer to integer. (False)


19) For deallocating memory, you can use __________ function (free())



20) Linked list can be used to implement stacks and queues. (True)



21) _____________ function is used to alter the size of a block which is previously allocated.

a)      alloc()

b)      free()

c)      realloc()

d)     malloc()


22) Besides the file pointers which we explicitly open by calling fopen, there are also _______________ predefined streams.

a)      Two

b)     Three

c)      One

d)     Four