M4.1-R3: 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 TEAR-OFF ANSWER SHEET only, attached to
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)
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 TEAR-OFF ANSWER SHEET only, attached to
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 “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)
1.1 The && and || operators
A) compare two numeric values
B) combine two numeric values
C) compare two Boolean values
D) combine two Boolean values
1.2 The break statement causes an exit
A) only from innermost loop
B) only from innermost switch
C) from the innermost loop or switch
D) none of the above
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most
appropriate one and enter in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)
1.1 The && and || operators
A) compare two numeric values
B) combine two numeric values
C) compare two Boolean values
D) combine two Boolean values
1.2 The break statement causes an exit
A) only from innermost loop
B) only from innermost switch
C) from the innermost loop or switch
D) none of the above
1.3 Assuming var1 has value 20. What will following code print?
Printf(“%d %d\n”, var1--, ++var1);
A) 20 20
B) 19 20
C) 20 21
D) 21 22
Printf(“%d %d\n”, var1--, ++var1);
A) 20 20
B) 19 20
C) 20 21
D) 21 22
1.4 When accessing a structure member, the identifier to the left of the dot operator is the
name of
A) a structure member
B) a structure tag
C) a structure variable
D) the keyword structure
name of
A) a structure member
B) a structure tag
C) a structure variable
D) the keyword structure
1.5 A static automatic variable is used to
A) make a variable visible to several functions
B) retain a value when a function is not executing
C) conserve memory when a function is not executing
D) none of the above
1.6 Which of the following directive creates functions like macros?
A) #include
B) #define
C) #undef
D) #ifdef
1.7 Which format specification is used in printf statement to print hexadecimal format
A) %i
B) %c
C) %x
D) %u
A) make a variable visible to several functions
B) retain a value when a function is not executing
C) conserve memory when a function is not executing
D) none of the above
1.6 Which of the following directive creates functions like macros?
A) #include
B) #define
C) #undef
D) #ifdef
1.7 Which format specification is used in printf statement to print hexadecimal format
A) %i
B) %c
C) %x
D) %u
1.8 What will be the output of the following program:
Main()
{
int val = 500;
int *ptr = &val;
int **ptr1 = &ptr;
printf(“val = %d”, **ptr1);
}
Main()
{
int val = 500;
int *ptr = &val;
int **ptr1 = &ptr;
printf(“val = %d”, **ptr1);
}
A) 500
B) address of ptr
C) contents of ptr
D) none of the above
1.9 size of operator returns the size in bytes of
A) identifier
B) type
C) identifier or type
D) array
1.10The value of variable x after executing the following code will be:
val = -200;
x = (val >= 0 ) ? val : -val
B) address of ptr
C) contents of ptr
D) none of the above
1.9 size of operator returns the size in bytes of
A) identifier
B) type
C) identifier or type
D) array
1.10The value of variable x after executing the following code will be:
val = -200;
x = (val >= 0 ) ? val : -val
A) 0
B) 200
C) -200
D) 1
B) 200
C) -200
D) 1
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one
and ENTER in the “tear-off” sheet attached to the question paper, following
instructions therein. (1 x 10)
2.1 The #undef directive removes a name previously defined with #define directive.
2.2 The ‘C’ program can have only one command line argument.
2.3 The goto statement causes control to go to a function.
2.4 If you don’t use a return type in the function declaration, the compiler assumes that the
function does not return anything.
2.5 An array element is accessed using the dot operator.
2.6 Continue statement skips all subsequent statements in the loop body and triggers the next
iteration for the loop.
2.7 The strcmpi function compares two strings irrespective of case.
2.8 For loop allows a statement or compound statement to be executed at least once.
2.9 The fread function reads formatted data from a stream.
2.10 In ‘C’, unsigned int can have maximum range of values between 0 to 65535.
and ENTER in the “tear-off” sheet attached to the question paper, following
instructions therein. (1 x 10)
2.1 The #undef directive removes a name previously defined with #define directive.
2.2 The ‘C’ program can have only one command line argument.
2.3 The goto statement causes control to go to a function.
2.4 If you don’t use a return type in the function declaration, the compiler assumes that the
function does not return anything.
2.5 An array element is accessed using the dot operator.
2.6 Continue statement skips all subsequent statements in the loop body and triggers the next
iteration for the loop.
2.7 The strcmpi function compares two strings irrespective of case.
2.8 For loop allows a statement or compound statement to be executed at least once.
2.9 The fread function reads formatted data from a stream.
2.10 In ‘C’, unsigned int can have maximum range of values between 0 to 65535.
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 “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)
word(s)/phrase(s) in column Y. Enter your selection in the “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)
X Y
3.1 Group of related data items A. ?:
3.2 A file not used for text processing B. Recursion
3.3 Reserved word C. Structure
3.4 A variable that keeps its value even after program D. typecast
exits the block in which it is declared
3.5 A data type used for saving storage area E. keyword
3.6 The process by which function calls itself F. Union
3.7 An operation in which value of one type converted G. Binary file
into value of different type.
3.8 An operator expressed in three part expression H. Call by reference
3.9 A sequence of bytes flowing into or out of program I. Automatic variable
3.10 An external source file that contains declarations and J. Executable file
definitions.
K. Type checking
L. Static variable
M. stream
N. Header File
3.1 Group of related data items A. ?:
3.2 A file not used for text processing B. Recursion
3.3 Reserved word C. Structure
3.4 A variable that keeps its value even after program D. typecast
exits the block in which it is declared
3.5 A data type used for saving storage area E. keyword
3.6 The process by which function calls itself F. Union
3.7 An operation in which value of one type converted G. Binary file
into value of different type.
3.8 An operator expressed in three part expression H. Call by reference
3.9 A sequence of bytes flowing into or out of program I. Automatic variable
3.10 An external source file that contains declarations and J. Executable file
definitions.
K. Type checking
L. Static variable
M. stream
N. Header File
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 “tear-off” answer sheet attached to the
question paper, following instructions therein. (1 x 10)
the list below. Enter your choice in the “tear-off” answer sheet attached to the
question paper, following instructions therein. (1 x 10)
A. Union B. 4 C. float
D. indirection E. NuLL F. semicolon
G. void H. header file I. Function
J. 2 K. pragma L. 5
M. integers N. Macro O. Recursion
D. indirection E. NuLL F. semicolon
G. void H. header file I. Function
J. 2 K. pragma L. 5
M. integers N. Macro O. Recursion
4.1 The expression 11%3 evaluates to __________.
4.2 In a 32 bit system float data type will occupy __________ bytes.
4.3 The closing brace of a structure is followed by __________.
4.4 A function that does not return anything has return type __________.
4.5 A(n) __________ cannot be passed to a function as an argument.
4.6 An instruction to the compiler to perform an action at compile time is called __________.
4.7 __________ is an example of derived data type.
4.8 Enumerations can be internally treated as __________.
4.9 Accessing a data object through a pointer rather than directly by name is called ______.
4.10 An identifier defined in a #define preprocessor directive to represent another series of
character is called __________.
4.2 In a 32 bit system float data type will occupy __________ bytes.
4.3 The closing brace of a structure is followed by __________.
4.4 A function that does not return anything has return type __________.
4.5 A(n) __________ cannot be passed to a function as an argument.
4.6 An instruction to the compiler to perform an action at compile time is called __________.
4.7 __________ is an example of derived data type.
4.8 Enumerations can be internally treated as __________.
4.9 Accessing a data object through a pointer rather than directly by name is called ______.
4.10 An identifier defined in a #define preprocessor directive to represent another series of
character is called __________.
PART TWO
(Answer any FOUR questions; Include appropriate documentation, wherever necessary)
5.
a) Develop a flowchart and then write a C program to display all prime numbers less than
the number entered by the user.
b) Explain the difference between an array, structure and an enumerated data type.
(10+5)
6. Write an algorithm and then develop a program to evaluate the roots of a quadratic
equation. Define and use a function cal_roots() to calculate the roots such that roots are also available in calling function i.e. use pointers.
(15)
(Answer any FOUR questions; Include appropriate documentation, wherever necessary)
5.
a) Develop a flowchart and then write a C program to display all prime numbers less than
the number entered by the user.
b) Explain the difference between an array, structure and an enumerated data type.
(10+5)
6. Write an algorithm and then develop a program to evaluate the roots of a quadratic
equation. Define and use a function cal_roots() to calculate the roots such that roots are also available in calling function i.e. use pointers.
(15)
7. Develop a flowchart and then write a C program to find the occurrence (single or
multiple) of a substring in a given string. The substring and string are entered by the user. Also point out the location at which the substring occurs.
(15)
multiple) of a substring in a given string. The substring and string are entered by the user. Also point out the location at which the substring occurs.
(15)
8.
a) Explain the difference between parameter passing mechanism “Call by value” and “Call
by reference”. Which is more efficient and why?
b) Develop a flowchart and logic to implement the stack data structure using link list.
(5+10)
a) Explain the difference between parameter passing mechanism “Call by value” and “Call
by reference”. Which is more efficient and why?
b) Develop a flowchart and logic to implement the stack data structure using link list.
(5+10)
9.
a) Draw a flowchart and then write a C program to enter the roll number and marks of any
three subjects of few students from the keyboard and write to a file.
b) It is said that “C is a middle level language and is good for system level programming.”
Describe three facilities available in ‘C’ which support this statement.
a) Draw a flowchart and then write a C program to enter the roll number and marks of any
three subjects of few students from the keyboard and write to a file.
b) It is said that “C is a middle level language and is good for system level programming.”
Describe three facilities available in ‘C’ which support this statement.
No comments:
Post a Comment