/> M3-R4: PROGRAMMIMG & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE JAN 2016

M3-R4: PROGRAMMIMG & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE JAN 2016

M3-R4: PROGRAMMIMG AND PROBLEM SOLVING 
THROUGH ‘C’ LANGUAGE JANUARY 2016

Q.1. Multiple Choice of Answers.

1.1 Which one is incorrect statement for C Language?
A) C does not perform any bound checking in array.
B) Two pointers cannot be added.
C) String with white space cannot be entered by any means.
D) All arithmetic operators can be used as shorthand operators.

1.2 What will be the output of the following code?
void fun(int x,int *y){x++; *y=x+x;}
main()
{
   int b=4,a=1;
  fun(3,&b);
 printf("%d %d",a,b);
}
A) 1 4
B) 1 8
C) 4 1
D) 8 1

1.3 Which one of the following is incorrect statement for singly linked list?
A) The link field always points to successor.
B) To access any arbitrary data is time consuming.
C) When number of elements is fixed, it is better to use linked list than array.
D) It is a dynamic data structure.

1.4 Which option is the most appropriate for the following code?
main()
{
  char c[10]="INDIAN"; int x;
for (x=4;x<7;x++)
printf("%*s",x,c);
}
A) INDIANINDIANINDIAN
B) Compiler generates error because of not sufficient space.
C) INDIINDIAINDIAN
D) Error because of invalid printf syntax.

1.5 Calculate number of iterations of while loop in the following code:
main()
{
  float d=3.14;
  short int b=1,c=4;
  while(b<c)
{
  b=(int)d;
  --b;
  c=c+1/2;
  printf("%d %d\n",b,c);
}
}
A) Infinite times
B) Syntax error
C) 3
D) None of the above

1.6 What will be the output of the following code?
main()
{
  int o=1%2,p=sizeof(float);
int q,r=5,s=10/2,t;
q=r>> && p>31-12%4 || r/q+3;
t=(p>q)?(s*r-2):(o/4%2);
printf("%d %d",o,s);
}
A) Syntax error due to unbalanced parenthesis.
B) Syntax error due to value of q cannot be calculated.
C) 1 5
D) 0 5

1.7 Which one is the binary operator group?
A) Conditional operator, bitwise XOR
B) << , += , dot
C) indirection, ! , ~
D) (int), ++

1.8 What will be the output of the following code?
main()
{
  int a,b;
a=3%4;
switdh(a/1)
{
  defaoult:printf("I");
  case 3:printf("T");

  case 2:printf("W");
  case 1:printf("O");
}
}
A) ITWO
B) TWO
C) Syntax error because break is missing
D) Syntax error because default is misplaced

1.9 Which one of the following is incorrect for structure?
A) It is a convenient tool to handle a group of logically related data items.
B) Structure of array variables can be passed as argument in a function.
C) It is a user-defined data type.
D) Structure within structure is not supported.

1.10 Which one of the following is VALID in C language?
A) printf("%d", ++4);
B) float n, a[n];
C) int *p=&a, a=3;
D) for( ; ; );

Q.2. TRUE or FALSE.


2.1 The formal arguments must be always variables.
TRUE

2.2 There is only one ternary operator in C.
TRUE

2.3 malloc( ) is used to allocate memory run time.
TRUE

2.4 sizeof is function that returns size of variables in bytes.
TRUE

2.5 int a[4]; Here 4 indicates size of an array and a[4]=3; here 4 represents 5th element.
TRUE

2.6 In self-referential structure, pointer is required as a data member.
TRUE

2.7 Union is a concept borrowed from array.
FALSE

2.8 default keyword is mandatory in switch case structure.
FALSE

2.9 if the file is open in read mode, we can't insert data into the file.
TRUE

2.10 In terms of memory usage, linked list is always better than array
TRUE


Q.3. Match words and phrases




SR NO.
X
Y(Ans.)
1
It is the default storage class of a variable
auto 
2
Smallest individual unit in a program is known as
C tokens
3
This loop is also known as exit-controlled loop
do..while
4
"2" is known as string constant
5
This character is used to indicate end of the FILE is
EOF
6
Control string required to print long int
%ld
7
Default return type of any user-defined function is
integer
8
This function is used to merge two strings in one strcat
9
It is a fixed size collection of similar data type
array
10
Logical NOT operator is
 Uniary


Q.4. Fill in the blank

4.1 Diamond shape is used to show ___condition_____ in a flowchart.

4.2 Data type of address of a variable is always ___unisigned int_____.

4.3 ____linker____ combines one or more object files and library code into executable file.

4.4 ____fseek____ function is required to access data in a file in random manner.

4.5 ____enum____ keyword is used to declare user-defined data type.

4.6 Structure definition must ends with ____semicolon____.

4.7 If the memory is not allocated run time, malloc( ) returns ___void pointer_____.

4.8 ___linked list_____ is better to store data in application when frequent insertion and deletion operations
are performed in application.

4.9 ___ampersand_____ symbol is used to indicate address of a variable.

4.10 ___typedef_____ allows users to define an identifier that would represent an existing data type.

Options.
A. void pointer
B. linker
C. enum
D. fseek
E. typedef
F. semicolon
G. unsigned int
H. process
I. address
J. linked list
K. condition
L. ampersand
M. asterisk


     Long Questions

Q.5.
a) Write a program that input a string and rearrange all the characters in alphabetical order.
b) Discuss the differences between actual and formal arguments using example.
c) How an array can be passed as an argument to a user-defined function?
(6+4+5)

Q.6.
a) Define structure employee having members: empid, name, basic, ta, da, hra, total salary. Write
a program that inputs empid, name and basic salary for 5 employees. Calculate the total salary
from data and display it along with ID and name.
(da=90% of basic, hra=10% of basic, ta=800)
b) Write a program to that asks filename from the user and create it. Using program insert text data
into the file and display the contents of the file on screen.
(8+7)

Q.7.
a) Write a menu driven program that first display options given below and asks to select an option.
If user opts
1. then check whether the number is perfect number or not
2. then check whether the number is palindrome or not
3. then immediately terminate the program.
(A positive integer that is equal to the sum of its positive integral factors, including 1 but
excluding itself. A palindrome number is a number that remains the same when its digits are
reversed.)
b) Write a program that enters a binary number and calculate its decimal equivalent. (Fox
example 10010=18)
(10+5)

Q.8.
a) Write a program to calculate nCr. Define and Use fact( ) function to calculate factorial of a
number. nCr = n! / ((r!) x (n-r)!)
b) Describe the various methods to input string from keyboard.
c)
(6+4+5)

Q.9.
a) Grades of steel is assigned according to the following conditions:
1. Hardness must be > 50
2. Carbon content must be > 0.7
3. Tensile strength must be > 5500
The grades are as follows:
If all the conditions are met then Grade is 10.
If conditions 1 and 2 are met then Grade is 9.
If conditions 2 and 3 are met then Grade is 8.
If conditions 1 and 3 are met then Grade is 7.
If none of the conditions are met then Grade is 6.
Write a program that asks values of hardness, carbon content and tensile strength of the steel.
Output the Grade of steel.
b) Explain the concept of structured programming in detail.
c) Differentiate: local variable vs global variable.
(6+5+4)
*****

0/Post a Comment/Comments

Leave a Reply

Previous Post Next Post