Pages

Tuesday, 12 July 2016

July- 2013 M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH ‘C’ LANGUAGE (Solve)

 July, 2013
M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH ‘C’ LANGUAGE
NOTE:
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and
PART TWO contains FIVE questions.
2. PART ONE is to be answered in the OMR ANSWER SHEET only, supplied with the
question paper, as per the instructions contained therein. PART ONE is NOT to be
answered in the answer book.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO will be
supplied at the table when the answer sheet for PART ONE is returned. However,
candidates, who complete PART ONE earlier than one hour, can collect the answer book for
PART TWO immediately after handing over the answer sheet for PART ONE.
TOTAL TIME: 3 HOURS TOTAL MARKS: 100
(PART ONE – 40; PART TWO – 60)

PART ONE
(Answer all the questions)

1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in the “OMR” answer sheet supplied with the question paper, following instructions therein. (1x10)

1.1 In the passage of text, individual words and punctuation marks are known as
A) Constants
B) Keywords
C) Operators
D) Tokens
Answer 


1.2 Choose the option that contains only valid hexadecimal integers.
A) 0x9F, 0xbcd, 0x1
B) 037, 0xx, 01000
C) 0x561u, 0x9h, 0xdd
D) H9F, HFF, HAA
Answer 

1.3 Which one of the following are not valid variable names in C?
A) float_int, keyword, A1
B) ANSI, ascii, cpu
C) valid, variable, name
D) None of the above
Answer 

1.4 What is the output of the following code?
main()
{ static int num=8;
printf(“%d ”,num=num-2);
if(num!=0) main(); }
A) 8 6 4 2
B) Infinite output
C) 6 4 2 0
D) Invalid because main function can’t call itself.
Answer 

1.5 What is the effect of the following code?
main() { int a[4] = {25, 16};
printf(“%d %d”, a[0] & a[1], a[1]|a[2]) ; }
A) 16 16
B) Syntax error because of invalid operator symbol
C) 25 16
D) Syntax error because of invalid array initialization
Answer 

1.6 What will be the output of the following code?
main() { int c,d, *p1=&c,*p2=&d, x;
c =10,d =4;
x = –3* – *p2 / *p1 + 5;
printf(“%d ”,x);
}
A) 6
B) Invalid syntax because / * is used for comments.
C) 8
D) Invalid syntax because three binary operators can’t be together in an expression.
Answer 

1.7 What is the output of the following code?
main(){ int a, b; a=b=4;
b=a++;
printf("%d %d %d %d", a++, --b, ++a, b--); }
A) 5 3 7 3
B) Syntax error
C) 5 4 5 3
D) 6 2 6 4
Answer 

1.8 When we declare an array
A) Compiler declare array name itself as a constant pointer to base address
B) A continuous file is allocated to store the elements value
C) Index of elements is declared automatically
D) All elements are initialized to zero
Answer 

1.9 The do…while looping statement
A) is executed only once if the condition is true.
B) is also known as entry-controlled loop.
C) is executed at least once if the condition is false.
D) is unconditional looping statement..
Answer 

1.10 What will be the output of the following code?
struct { int si;
double d;
float *cp; } s ;
void main() {
printf(“%d, %d, %d”, sizeof(s.d), sizeof(s.cp), sizeof(s)); }
A) 4, 4, 12
B) 8, 2, 12
C) 10, 4, 16
D) 8, 4, 14
Answer 

2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and ENTER in the “OMR” answer sheet supplied with the question paper, following instructions therein. (1x10)

2.1 #define is known as preprocessor compiler directive.
2.2 The return type of malloc function is void.
2.3 sizeof( ) is a function that returns the size of a variable.
2.4 Only character or integer can be used in switch statement.
2.5 for(i=0; i<5;i++); statement has syntax error because of semicolon at the end.
2.6 Linking is the process of putting together other program file and functions that are required by the program.
2.7 ‘auto’ keyword is used to declare a local variable.
2.8 Algorithm is the graphical representation of logic.
2.9 Size of the pointer variable depends on the data type that it points to.
2.10 Linked list must require continuous memory allocation unlike array.

Answer


3. Match words and phrases in column X with the closest related meaning/word(s)/phrase(s) in column Y. Enter your selection in the “OMR” answer sheet supplied with the question paper, following instructions therein. (1x10)

                      X                                                                            Y

3.1 This concept is borrowed from                                  A. long
structure for constructing data type
3.2 Number of operators required in ?: operator            B. int
3.3 Data type of argument counter (argc) in                  C. union
command line argument
3.4 Only this symbol is allowed in a valid                     D. do…while
variable name
3.5 Keyword used to indicate global variable               E. underscore
3.6 It is the exit controlled looping statement               F. getc
3.7 To declare unsigned long integer variable              G. double
this suffix is used with value
3.8 To insert the comments in the program this            H. extern
symbol is used
3.9 Return type of ftell function                                    I. array
3.10 This function is used to read a character from      J. three
a file
                                                                                      K. /*
                                                                                      L. while
                                                                                      M. UL

Answer


4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in the list below. Enter your choice in the “OMR” answer sheet supplied with the question paper, following instructions therein. (1x10)

4.1 Type casting is a ________ operator.
4.2 Array is ________ type of data type.
4.3 ________ is an unconditional jump statement.
4.4 ________ operator is used to compare two entities.
4.5 ________ data structure can grow or shrink in size during the execution of a program.
4.6 A variable declared inside a function is called ________ variable.
4.7 The ________ operator is true only when both the operands are true.
4.8 ________ keyword allows user to define an identifier that would represent an existing data
type.
4.9 ________ function is used to move the file position to desired location within the file.
4.10 ________ function is used to change the memory size already allocated run time.

A. primitive                          B. goto                       C. and
D. linked list                         E. derived                  F. fseek
G. indirection                       H. local                      I. typedef
J. free                                   K. relational              L. unary
M. global

Answer

PART TWO
(Answer any FOUR questions)

5.
a) Write a program to calculate number of vowels (a,e,i,o,u) separately in an entered string.
b) Explain the working of shorthand assignment operators, pre and post increment operator
and the ternary operator.
c) What is pointer? How is it initialized? What is indirection operator? What is the scale factor
of a pointer? What is the size of a pointer variable?
(6+4+5)

6.
a) Write a program having function print_char( ) which receives a character and n integer as
arguments. The function should print n times the entered character.
b) Write a ‘C’ program to computer the average of every third integer lying between 1 and 200?
Include appropriate documentation.
c) How to create a file in C? Why should a user close the file?
(5+5+5)

7.
a) Define recursion. Write a complete program to evaluate the given series using recursive
function sum( ). Here n is user dependent.
1 + 2 + 3 +…+ n
b) How Compilation, Linking and Loading are related? Also explain the basic task of a
Compiler, Linker and Loader?
c) How does passing an array as an argument to a function differ from call by value?
(6+4+5)

8.
b) Write a program to create a link list. There should be 20 nodes in the list, each node
contains an integer between 1-20. The list should be printed at the end.
(8+7)


9.
under: (Senior citizen: Age<60)

For All Tax
Rs.0 to 2,00,000 0% of income
2,00,001 - 5,00,000 10% on income excess of 2,00,000
5,00,001 - 10,00,000 30,000+20% on income excess of 5,00,000
Above Rs.10,00,000 1,30,000+30% on income excess of 10,00,000

For Senior Citizen Tax
Rs.0 to 2,50,000 0% of income
2,50,001 - 5,00,000 10% on income excess of 2,50,000
5,00,001 - 10,00,000 25,000+20% on income excess of 5,00,000
Above Rs.10,00,000 1,25,000+30% on income excess of 10,00,000

b) Write a program that copies contents of a text file into another file. Use command line
arguments to enter source and destination file name. If source file does not exist print
appropriate message and terminate the program.
(10+5)

No comments:

Post a Comment