Tuesday, 5 June 2018



1.Which of the following correct in c Language:-

A .  C does not perform any bound checking in array.
    B.  Two pointer cannot be added
    C.  String with white space cannot be entered by any means
    D.  All arithmetic operators can be used as shorthand operators.
  

2.find output
main()
{
Int o=1%2, p=sizeof(float);
Int q,r=5,s=10/2,t;
q=r>>2&&p>31-12&4||r/q+3;
t=(p>q)?(s*r-2):(o/4&2);
printf(“%d%d”,o,s);
}

3 which of the following is a binary operator group?
    A.  Conditional operator,bitwise XOR 
    B.  <<,+=,dot
    C.  Indirection,|,~
    D.  (int,++

4. Which of the following is the correct order of evaluation for the below expression?
z = x + y * z / 4 % 2 – 1
A) * / % + - =
B) = * / % + -
C) / * % - + =
D) * % / - + =

5.  When following piece of code is executed, what output will be generated?
#include <stdio.h>
int main()
{
char arr[7]="Network";
printf("%s", arr);
return 0;
}
A) Network
B) N
C) Garbage value
D) Compilation error

 6 The result of a Relational operation is always
 A) either True or False
 B) is less than or is more than
 C) is equal or less or more
 D) All of the above

7 The keyword used to transfer control from a function back to the calling function is
A) switch
B) goto
C) go back
D) return

8 Which of the following cannot be used as identifiers?
A) Spaces
B) Digits
C) Underscores
D) Letters

9 What will be the output of the following code segment?
 int x = 24, y = 39, z = 45;
z = x + y;
y = z - y;
x = z - y;
printf("\n%d %d %d", x, y, z);

A) 24 39 63
B) 39 24 63
C) 24 39 45
D) 39 24 45

10 What will be the output of the following code segment if Hello there is given as input?
char a[20];
scanf("%s", a);
printf("%s", a);
 A) Hello there
 B) Hello
 C) "Hello there"
 D) "Hello"

11 What will be output if you will compile and execute the following c code?
 #include int main()
{
 int a=5;
 float b;
 printf("%d",sizeof(++a+b));
 printf(" %d",a);
 return 0;
}

A) 2 6
B) 4 6
C) 2 5
D) 4 5

12 The result of a Relational operation is always
 A) either True or False
 B) is less than or is more than
 C) is equal or less or more
 D) All of the above

13  The keyword used to transfer control from a function back to the calling function is
 A) switch
 B) goto
 C) go back
 D) return

14 Which of the following can not be used as identifiers?
A) Letters
B) Digits
C) Underscores
D) Spaces

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

16 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

17 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

18 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.

19 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

20 If a=8, b=3 and c=-5 are integers, then value of a*b/c is
 A) -4
 B) -2.8
 C) +2.8
 D) +3

21 Which of the following is a valid identifier?
 A) 1return
 B) return1
 C) return
 D) $return_1

22 Which of the following is a valid string constant?
    A)  “programming” 
    B)   “programming
     C) ‘programming
         D) $ programming $

   23  f i = 8 and j = 5 are two integers, then the value of (i>0) || (j < 5) is
   A)  -5
   B)  1
   C)  0
   D)   5

24 Which of the following language is predecessor to ‘C’ Programming Language?
         A)  A  
         B) B
    C) ADA
    D) C++

25 The value of S[5] in the segment char s[15] = “ MICROPROCESSOR” is
 A) P
 B) O
 C)  R 
 D) None of the above

26 Function putchar() displays
 A) one word at a time on the screen
 B) one character at a time
 C) result on the screen
 D) None of the above

27  The sqrt() function is available in
 A) conio.h
 B) string.h
 C) math.h
 D) graphic.h

 28 If ‘a’ is an integer variable, then a = 5/2 will return a value
 A) 2.5
 B) 2
 C) 2.000000
 D) 2.500000

29 Which of the following a not a basic data type used in C language?
 A) double
 B) float
 C) char
 D) array

30  pow(x,y) is used to
A)  power of yx
B)   power of xy
C)   logarithm of x on the base y
D)  Such function does not exist

31 What would be value of j after the following is executed?
 k=17; j=6; if (k < 10) j=8; j=j+1; j=j+2;
A) 8
B) 9
C) 7
D) 10

32 In an assignment statement a=b; which of the following statement is true?
A) The variable a and the variable b are same.
 B)  The value of variable a is assigned to variable b, and the value of variable b is assigned to variable a.
C) The value of b is assigned to variable a but if b changes later, it will effect the value of variable a.
D)The value of b is assigned to variable a but if b changes later, it will not effect the value of variable a.
33 What is the value of r after this code is executed? r=2; k=8; if (r>3 || k>6 && r 10) r=50; else r=9
A) 9
 B) 2
C) 6
D) 50
34  Which of the following is not a valid relational operator?
A)  <
B)   =
C)   >=
D)   <=
35 Which is an incorrect variable name?
A) Id_No
 B) ID_NO
 C) IdNo
D) Id No
36 In which order do the Relational, Arithmetic, Logical and Assignment operators get evaluated in C? 
A) Arithmetic, Relational, Logical, Assignment
 B) Relational, Logical, Arithmetic, Assignment
C) Logical, Relational, Arithmetic, Assignment
 D) Assignment, Arithmetic, Relational, Logical

37 By default a real number is treated as a
 A) float
B) double
C) long double
D) integer

38 The && and | | operators
 A) compare two numeric values
B) combine two numeric values
C) compare two boolean values
D) None of the above

39 ‘C’ Programming Language was developed and written by
A) Martin Richards
B) Dennis Ritchie
C) Ken Thompson
 D) Herman Hellorith

40 Which of the following is false in ‘C’ Programming Language
 A) Keywords can be used as variable names
 B) Variable names can contain digits
 C) Variable names do not contain blank spaces
D) Capital letters can be used in variable names.

41 What will be the output of the following ‘C’ program
 main()
 {
 int a=5;
 float b=5.0;
if(a==b)
printf(“a and b are equal”);
else
 printf(“a and b are different”); }
A)  a and b are equal
B)   B) a and b are different
C)  C) Error
D)   D) None of the above

42 What will be the output of the following ‘C’ program?
main()
 { i
nt a=1;
int b=5;
if(a=5||b>10)
printf(“I will certainly pass”);
else
printf(“I am not so sure about the result”); }
A) I will certainly pass
B) I am not so sure about the result
C) Error
 D) None of the above

43 What will be the output of the following program? main() { int a; printf(“%d”,a); }
A) 0
B) 1
C) Error
 D) Unpredictable Value

44 A ‘C’ expression contains relational, assignment and arithmetic operators. There are no parentheses used. They will be evaluated in which of the following order
A)  Assignment Relational Arithmetic
B)  Arithmetic Relational Assignment
C)   Relational Arithmetic Assignment
D)   Assignment Arithmetic Relational

45 By default a real number is treated as a
A)  Float
B)   double
C)   long double
D)   integer

46 The operator & is used for
A)  Bitwise AND
B)  B) Bitwise OR
C)  C) Logical AND
D)  D) Logical OR

47  What is the output of the following program segment?
#include main()
{
 int i=10, m=10;
clrscr();
printf(“%d”, i>m?i*i:m/m,20);
getch();
}
A)  20
B)   1
C)  120
D)   100 20

48 An expression contains assignment, relational and arithmetic operators. If parentheses are not specified, the order of evaluation of the operators would be:
A)  assignment, arithmetic, relational
B)  relational, arithmetic, assignment
C)  assignment, relational, arithmetic
D)  arithmetic, relational, assignment

49 int z, x=5, y=-10, a=4, b=2; z=x++ - --y * b / a;
  What will be the final value of z?
A) 5
B) 6
C) 10
D) 11

51  Suppose that x is initialized as: short int x; /* assume x is 16 bits in size */ What is the maximum number that can be printed using
printf (“%d\n”, x),
 A) 127
B) 128
C) 255
D) 32,767

 52  When applied to a variable, what does the unary “&” operator yield?
 A) The variable’s address
B) The variable’s right value
C) The variable’s binary form
D) The variable’s value

53 The && and || operators
A) compare two numeric values
 B) combine two numeric values
C) compare two Boolean values
 D) combine two Boolean values

54 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 21

55 Which of the following directive creates functions like macros?
 A) #include
 B) #define
C) #undef
D) #ifdef

56 Which format specification is used in printf statement to print hexadecimal format
 A) %i
 B) %c
 C) %x
 D) %u

57 size of operator returns the size in bytes of
A) identifier
B) type
C) identifier or type
 D) array

58 The 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

59 Which of the following is a valid octal constant?
 A) 32
B) 032
 C) 049
D) 0x49

60 What will be the output of the following?
main()
{
int a = ‘A’;
 printf(“%d”, a);
A) 65
B) A
C) a
D) the program will not compile as an integer variable is assigned a character constant.
61. Which one is incorrect statement for C Language?
A) C compiler supports octal integer constant.
B) C compiler supports hexadecimal integer constant.
 C) C compiler supports binary integer constant.
 D) C compiler supports decimal integer constant.

62. What will be the output of the following code?
int main()
 {
 int x,y,z;
 x='1'-'0'; /* line-1 */
y='a'-'b'; /* line-2 */
z=x+y;
printf("%d",z); }
 A) 0
 B) Error because of incorrect line-1 only.
 C) Error because of incorrect line-1 and line-2.
 D) Error because of incorrect line-2 only.

63. Which of the following cannot be used as identifiers?
A) spaces
B) digits
C) underscores
D) letters

64. Precedence is used
A) To determine which operator evaluated first from left to right.
B) To determine the level of an operator in a program.
C) To determine how an expression involving more than one operator is evaluated.
 D) To check the expression is valid or not.

65. Identify the correct sequence of steps to run a program
A) Link, Load, Code, Compile & Execute
B) Code, Compile, Link, Execute & Load
C) Code, Compile, Link, Load & Execute
D) Compile, Code, Link, Load & Execute

66. What will be output if you compile and execute the following ‘C’ code?
void main()
{
 int i=4,x;
x=++i + ++i + ++i;
printf("%d",x); }
A) 21
B) 18
C) 12
D) Compilation error

67. What will be the output of following program
 #include main()
{
int x,y = 10;
x = y * NULL;
printf(“\n %d \n", x);
}
A) error
B) 0
C) 10
D) Garbage value

True and false
1.  Sizeof function that returns size of variable in bytes.
2.  Comma operator is used for separation.
3.  All of the following are expressions in c.
               i.      A=2+(b=5);
              ii.      A=b=c=5;
            iii.      A=11%3;
4.  Expression if a(=6).
5.  A variable is a string that varies during program execution.
6.  C language cannot be used for database manipulation.
7.  In the expression a=b=5 the order of assignment is not decided by associativity of operators.
8.  A printf statement can be used to display output on different lines.
9.   # is used to insert comments in the program.
10.           Calling a uninitialized variable will provide zero value.
11.           #define is known as preprocessor compiler directive.
12.           Sizes of short integer and long integer would vary from one platform to another.
13.           Every ‘if’ statement must also include ‘else’.
14.           If we have to execute the program with different set of inputs, we need to recompile the program each time.
15.            Compiler translates the of source code into object code before the program can be executed.
16.           The programming language happens to be the high level language with some assembly language features.
17.           In C the graphics may be used to add graphical features to the program.
18.           Every variable in c have three most fundamental attributes: Name, Value, Address.
19.           The operating system converts the ‘C’ program into machine language.
20.           Every function in ‘C’ must have a “return” statement.
21.           C is an object oriented programming language.
22.           Sizes of short integer and long integer would vary from one platform to another.
23.           Two different operators would always have different associativity.
24.           A preprocessor directive is a message from compiler to the linker.
25.           cout and cin can be used for output and input respectively in ‘C’ language.
26.            The default initial value of a static int variable is zero.
27.           Size of short integer and long integer can be verified using the sizeof() operator.
28.           Right shift of an unsigned integer by one bit is equivalent to multiplying it by two.
29.           In computer programming, the translation of source code into object code is done by a compiler.
30.           Scalar data types are not supported by ‘C’ language.
31.           The associativity of operator ! is from left to right. . 2.5 J++ executes faster than J+1 because ++ is faster than +.
32.           sizeof(‘a’) is not 1
33.           ‘C’ programs are converted into machine language with the help of an interpreter.
34.             Every ‘C’ program must contain a main( ).
35.            Putchar( ) is used only for single character input
36.           36 A printf( ) statement can generate only one line of output.
37.            The #undef directive removes a name previously defined with #define directive
38.           If you don’t use a return type in the function declaration, the compiler assumes that the function does not return anything.
39.           In ‘C’, unsigned int can have maximum range of values between 0 to 65535.
40.           An escape sequence begins with a backward slash followed by an alphabetical character
41.           NULL is a keyword in C.
42.           1.0 is an example of double constant and float constant.
43.           #define is used to define symbolic constant.
44.           const is a keyword that is used to define symbolic constant.
45.           The following block of code sums up an input series of grades (terminated by -1).

while( grade != -1 )
total = total + grade;
counter = counter + 1;
printf( "Enter grade, -1 to end: " );
scanf( "%d", &grade );
46.            A double data type number uses 64 bits giving a precision of 14 digits.
47.            Every C program must have at least one main ( ) function section.

48.            The precedence of arithmetic operators is (from highest to lowest) %, *, /, +, –
49.           Is the following statement valid in C? int my_num=100,000;
50.           We need to recompile the program before executing it even if there is no change in the source code.

Match the following
(A)
1.
Smallest individual unit in a program is known as
A
integer
2.
“2 “ is known as
B
4
3.
Control string required to print long int
C
ceil
4.
Default return type in any function is
D
String Constant
5.
Logical not operator is
E
%ld
6.
Size of long int n byte
F
C Tokens
7.
Terminates program
G
Unary
8.
Explicit conversion
H
main()
9.
Unary operator
I
three
10.
Number of operators required in ?: operator
J
/*
11.
To insert the comments in the program this symbol is used
K
exit()
12.
Size of float and double in bytes
L
Typecasting
13.
Round off a value 1.66 to 2.0
M
++
14.
Input/output function prototypes and macros are defined in
N
header
15.
This is a mandatory function in every ‘C’ program. Execution starts from this function
O
4,8









(B)
18.
 Preprocessor commands are also known as
A
Converts a data type to another data type
19.
 Formatted print is used to
B
Stdio.h
20
exit(0) in a ‘C’ program represents
C
‘a’ is a single character constant and “a” is a string character constant
21
Typecasting
D
directives
22
The difference in ‘a’ and “a” is
E
!
23

F
Take printout in special format
24
The operator && is an example of
G
directives
25
Header files in ‘C’ contain
H
#
26

I
logical
27
Preprocessor commands are always preceded by
J
main()
28
The bitwise AND operator is used for
K
\0
29
exit( ) function is used to terminate the
L
b=a
30
Null character is represented by
M
Library functions
18.
 Preprocessor commands are also known as
N
Take printout in special format
19.
 Formatted print is used to
O
Program


P
Termination of a program


Q
masking





(c)
31
Operator for giving remainder
g
Binary file
32

h
masking
33
assignment of a with b
i
a^=b^=a^=b
34
Which is not possible in C?
j
program
35
Which is not portable?
k
%
36
Compiler converts a source File to
l
Static variable
37
Reserved word
m
?:
38
Swap a and b without temporary variable
n
Header File
39

o
Typecasting
40
A sequence of bytes flowing into or out of program
p
keyword
41
An operator expressed in three part expression
q
Object file
42
An external source file that contains declarations and definitions.
r
a=b
43
Converting to a different data type
s
stream
44
Pictorial representation of logic
t
#define
45
Defining constants
u
Declaration
46
Space allocation to variables
v
nothing


w
Pictorial representation of logic


Fill  in the blank
A
Stdio.h
E
Header file
I
exit
M
flowchart
B
ampersand
F
Ctype.h
J
and
N
String
C
condition
G
Bit
K
++
O
Single quotes
D
Unsigned integer
H
%10s
L
Relational
P
logical operators



Q
Main()
U
0's and 1's
Y
1 byte
c
Logical operator
R
void
V
stdout
Z
Array of characters
d
max
S
Left to right
w
preprocessor
a
\b
e
Ternary operator
T
*
X
2
b
65
f
4

g
macro
h
false
i
void

1.  Diamond shape is used to show ________in a flowchart.
2.  Data type of address of a variable is always _________
3.  _______ symbol is used to indicate address of a variable.
4.  NULL is macro constant which has been defined in the header file._________
5.  The smallest data item a computer can process is called a(n)._____.
6.  Name the header file to be included for the use of built in function isalnum() is ________.
7.  Format code in printf to print exactly 10 characters is ________.
8.  An operator which can change the value of a variable on the right hand side of an expression is ________.
9.  A library function ________ causes an exit from the program in which it occurs.
10.           ________ operator is used to compare two entities.
11.           The ________ operator is true only when both the operands are true.
12.           NULL macro is defined in ________ file
13.           Character constants should be enclosed between ________.
14.           Pictorial representation of an algorithm is ________.
15.           The operator && is an example for ________ operator
16.           p++ has associativity ________.
17.           The standard file, in ‘C’, ________ is connected to screen.
18.           Ultimately, all data items processed by a computer are reduced to combinations of ________.
19.           If a function return type is declared as ________ it cannot return a value.
20.           A group of related characters that conveys meaning is called a ________.
21.           The ________ is a program that is executed before the source code is compiled.
22.           The operator i << 2 is equivalent to ________ i by 4.
23.           Size of char data type is ________.
24.           In ‘C’, strings are stored in the form of ________.
25.           Escape sequence for backspace is ________.
26.           The ASCII value, in decimal, of character ‘A’ is ________.
27.           ________ are used when we want to test more than one condition and make decision.
28.           The only operator that contains three operands is ________ operator.
29.           Preprocessor directives are placed in the source program before the function ________.
30.           #define statement calls for simplest type of ________ substitution
31.           printf(“%.*s”, max, s) can be used to print at most ________ characters from a string s.
32.           The expression 11%3 evaluates to __________.
33.           In a 32 bit system float data type will occupy __________ bytes
34.           A function that does not return anything has return type __________.
35.           An identifier defined in a #define preprocessor directive to represent another series of character is called __________.
36.           In expression ((j + k > 10) || (n > -3)), (n > -3) will be evaluated if (j + k > 10) is ________.

Fill in the blank (2)
A.  scanf
B. Conditional Operator
C.Math.h
D. integer
E.  Long Integer
F.  ?:
G. char
H. 8
I.\\
J. ||
K.  Type Conversion
L.
M.
N. Macro
O.

1.  M_PI is a constant that represents 22/7 ratio. It is declared in ________ header file.
2.  ________ function reads data from stdin stream.
3.  A pair of question mark and colon is known as ________.
4.  Constant value 32767L is an example of______
5.  Return type of printf function is______
6.  In ‘C’ size of data type varies from compiler to compiler. In TURBO C 3.0 (16 bit compilers) size of: double is ______ byte
7.  ______ is a ternary operator.
8.  Character constants are coded using double quotes ____________
9.  A single line comment in C language source code can begin with ________.
10 ________ is a logical OR operator.
11 #define allow us to define ________.
12 ________ is a way to promote from lower to higher data type.
Question and answer
1.  Grade of steel is assigned according to the following conditions:
A.  Hardness must be >50
B.  Carbon content must be >0.7
C.  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.
2.What will be output of the operations below?
main()
 {
int a=10,b=25;
 a=b++ + a++;
 b= ++b + ++a;
 printf(“%d %d \n”,a,b); }
2.  Define void data type
3.  Write a C program that displays the recommended actions depending on the color of a traffic light using the if statement..
4.   In the following declaration statement: char c=’A’; Variable c stores one byte of memory space while character constants ‘A’ stores one byte memory space. How one byte variables can stores two byte character constant? What is automatic type promotion in c?
5.  What will be printed as the result of the operation below?
main()  { int x=20,y=35; x=y++ + x++; y= ++y + ++x; printf(“%d %d \n”,x,y); }
6.  Write a ‘C’ program to find size of structure without using sizeof operator
7.  What are preprocessor directions? Why do we need them? Explain various preprocessor directives?
8.  Explain the working of shorthand assignment operators, pre and post increment operator and the ternary operator.
9.  How Compilation, Linking and Loading are related? Also explain the basic task of a Compiler, Linker and Loader?
10.           Distinguish between compiler error and runtime error with the help of an example
11.           What is a preprocessor and what are the advantages of preprocessor? What are the facilities provided by preprocessor?
12.           What is meant by formatted output? Mention the output of the following commands. int n = 28; i) printf ( “% 5d,”n); ii) printf ( “%+5d”, n); iii) printf ( “%+5d”, n);
13.           Give an example of conditional expression
14.           What is the significance of header file in a C Program? What do the header files usually contain?
15.           Evaluate the following expressions, indicating which ones are true or false. 1. 10 = = 9 + 1 2. 10 && 8 3. 8 || 0 4. 0 && 0 5. Let X = 10 and Y=9; X >= 8 && Y <= X
16.           How Compilation, Linking and Loading are related? Also explain the basic task of a Compiler, Linker and Loader.
17.             List out the rules to declare a valid variable in ‘C’ program. Evaluate the following expression and show the hierarchy of operations: (2 + 4)/3 + 2 % 3 * 2 – 5
18.           What are the disadvantages of nested if-else statement?
19.           Write a ‘C’ program to calculate the electricity bill using if..elseif, as per the following details * Given the number of units consumed, unit charges are as follows:
i)             For first 50 units Rs. 0.50/unit ii) For next 100 units Rs. 0.75/unit iii) For next 100 units Rs. 1.20/unit iv) For unit above 250 Rs. 1.50/unit * Add fuel surcharge 20% and Govt. Tax 10% on bill to calculate the total bill.
20 WAP for swaping two variable
21 What are the commonly used input functions in ‘C’? Write their syntax and explain the purpose of each.
22 What are logical, syntactic and execution errors? Give examples of each. Which is most difficult to find and why?
23  Enumerate features of a good ‘C’ program. Describe the commonly used techniques as to how ‘C’ programs can be made highly readable and modifiable.
24  What is an algorithm?
25 Write a function that will compute Y = X^n Where Y and X are floating point numbers and n is an integer number. Use this function and print the output
 X n Y … … …
26  ‘C’ compiler supports many pre-processor commands. Write their names only.
27 What is an execution error? Differentiate it from syntactic error. Give examples
28  It is said that ‘C’ is a middle level assembly language. Mention those features of ‘C’ which enable this description.
29 Write an algorithm and then develop a program to evaluate the roots of a quadratic equation.
29 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.
30. What do you understand by loading and linking of a program?
31. Explain the role of linker and loader in compilation.
32. Explain working of bit-wise exclusive OR and shift left operators in C with example.
33. Write a ‘C’ program to swap two variables without using third variable.
34. Write a ‘C’ program in which a scanf() function can read a complete paragraph of text.
35. How can you create your own header file in ‘C’ programming? Briefly explain.












No comments:

Post a Comment

ch-12 File Handling

Mcq 1. What does fp point to in the program?   #include<stdio.h> int main() {   FILE *fp;   fp=fopen("trial",...