Sei sulla pagina 1di 36

QUESTION BANK

Subject: Basic Computation & Principles of Computer Programming Discipline: B-


Tech (All) Subject Code: CS201 Semester: 2ND
[PART
-A]
Multiple Choice Questions
(each question carries 1 mark)
Choose the correct alternative in each of the following:
1. Operating system is
(a) Application Software
(b) System
software
(c) Both of these
d) None of these
2. ALU is a part
of a) Memory
b) CPU
c) Output device
d) input device
3. Pointer is
a) a variable containing the address of a variable
b) a value
c) a memory location
d) none of these
4. Which will be the output?
void main()
{
int x=7, y=5;
x=y++ + x++;
y=++y + ++x;
printf(“%d %d”, x, y);
}
a) 12 14
b) 12 20
c) 9 7
d) 12 19
5. Which will be the output?
void main()
{
int sum=0,i;
for (i=0;i<=10;i++)
{
if (i%2) continue;
sum=sum+i;
printf(“%d”,sum)
}
}
a) 55
b) 23
c) 30
d) 42
6. Which will be the output?
void main()
{
int i=2;
switch(i)
{
case1: printf (“one”);
case1: printf (“two”);
case1: printf (“three”);
default: printf (“error”);
}
}
a) one two three error
b) two
c) two three error
d) two three
7. A 32-bot microprocessor has the word length equals to
a) 2 bytes
b) 1 byte
c) 4 bytes
d) 8 bytes
8. The output of
int i=5;
printf(“%d %d %d”, i, i++, ++i);
is
a) 5 5 7
b) 5 6 7
c) 7 6 5
d) 7 6 6
9. The output of
void main ()
{
int arr[6]={20, 25};
printf (“%d %d %d”, arr[2], arr[3], arr[4]);
}
is
a) 0 0 0
b) 20 25 0
c) 25 0 0
d) none of these
10. A function may contain
a) one return statement
b) two return statements
c) more than two return statements
d) none of these
11. RAM stands for
a) Read-write Access Memory
b) Read Access Memory
c) Random Access Memory
d) None of these
12. Which one of the following is a Bitwise operator?
a) < b)
>= c)
&& d)
<<
13. The output of
int fact=1;
for(i=0;i<5;i++);
{
fact=fact*i;
printf(“%d”, fact);
}
is
i)
24 ii)
5
iii) Infinite loop
iv) None of these
14. Which one of the following declaration is invalid?
a) int 2A
b) int A2A
c) int A2
d) int AA2
15. Which one is the correct output?
char a[]=”computer”;
printf(“%d”, strlen(a));
a) 9
b) 10
c) 8
d) 11
16. In hexadecimal system F is equivalent to the number in decimal is
a) 10
b) 12
c) 13
d) 15
17. What will be the value of i and m after executing the following code?
int i=1,m;
m=i++;
a) 2,1
b) 1,1
c) 1,2
d) None of these
18. Memory of a union uses
a) Different storage location
b) No storage location
c) Same storage location
d) None of these
19. CU is a part of
a) CPU
b) Memory
c) ALU
d) Input device
20. Which one of the following has fastest access time?
a) Main memory b)
Cache memory
c) Secondary memory
d) Register
21. Register set is a part of
a) Memory
b) CU
c) ALU
d) CPU
22. What is the value of (560)10 in octal number system?
a) (1060)8
b) (450)8 c)
(1000)8 d)
(1160)8
23. Which is the range of unsigned short integer?
a) 0 to 65535
b) 0 to 255
c) -128 to 127
d) None of these
24. Which of the following is a special operator?
a) <<
b) ++
c) ?:
d) sizeof()
25. Which will be the output of the following code?
int x=9;
if(10)
printf(“%d”,++x);
else
printf(“%d”,x++);
a) 9 b)
10 c)
11 d)
12
26. The function ftell()
a) Reads a character from a file
b) Reads an integer from a file
c) Gives the current position in a file
d) None of these
27. Which will be the output?
void main ()
{
int i, j; for(i=0,j=5;i<j;i+
+,j++); printf(“%d %d”,
i, j);
}
a) 3 2
b) 0 5 1 4 2 3
c) Error
d) Infinite loop
28. ASCII value of ‘A’ is
a) 97
b) 65
c) 48
d) 67
29. Which will be the output?
# define SQR(x) x*x
main ()
{
int x=5, y;
y=4*SQR(x-3);
printf(“%d”, y);
}
a) 8 b)
64 c)
16 d)
-52
30. Which will be the output?
# define int char
void main ()
{
int i=65;
printf (“%d”, sizeof(i));

}
a) 1
b) 2
c) 4
d) 8
31. Which is the correct output?
void main ()
{
int i=5, j=6, z;
printf (“%d”, i+ ++j);
}
a) 12
b) 11
c) 10
d) 13
32. What is the value of (560)10 in hexadecimal number system?
a) (230)16
b) (200)16
c) (120)16
d) (260)16
33. What is the value of (2230)10 in hexadecimal number system?
e) (230)16
f) (200)16
g) (120)16
h) (260)16
34. What will be the result of (1010)2 + (1100)2?
a) (10110)2
b) (11010)2
c) (10100)2
d) None of these
35. What will be the result of (11010)2 - (10111)2?
a) (2)8
b) (3)8
c) (4)10
d) (00100)2
36. The purpose of mode r+ is to
a) Open only for reading
b) Open only for writing
c) Open for both reading and writing
d) None of these
37. What will be the result of (110)2 + (100)2?
a) (1010)2
b) (1110)2
c) (1000)2
d) None of these
38. What will be the result of (1010)2 - (0101)2?
a) (5)8
b) (7)8
c) (3)10
d) (0100)2
39. What will be placed in exponent field in case of the number (11.1010)2?
a) 1010
b) 4
c) 11
d) 11.1010
40. What will be the equivalent binary number of (1456)10?
a) (10110110000)2
b) (11110110100)2
c) (10111110000)2
d) (11110110000)2
41. What is the command to copy a file in DOS if src.txt is the source file and dst.txt is the destination
file?
a) copy src.txt dst.txt
b) copy dst.txt src.txt
c) copy from src.txt to dst.txt
d) copy from src.txt in dst.txt
42. The output of int
fact=1;
for(i=0;i<fact;i++)
{
fact=fact*i;
printf(“%d”, fact);
}
is
a) 24
b) 5
c) Infinite loop
d) None of these

43. Which of the following command is used to calculate the length of a string?
a) strlen
b) strln
c) strlength
d) strlgth
44. Which will be the output?
# define SQ(x) x*x
void main ()
{
int a=5, b; b=-
SQ(a+2);
printf(“%d”, b);
}
a) 7
b) -49
c) -17
d) None of these
45. Which will be the output?
void main ()
{
static int a=5;
a=a+3;
printf(“%d”, a);
}
a) 8
b) 5
c) Error
d) None of these
46. Which will be the output?
void main ()
{
int i=0;
do
{
i=i+2;
} (while i<3);
a) 4
b) 6
c) 2
d) None of these

47. What is the size of integer data type?


a) 2 bytes
b) 1 bytes
c) 4 bytes
d) 8 bytes
48. What is the size of float data type?
e) 2 bytes
f) 1 bytes
g) 4 bytes
h) 8 bytes
49. What is the size of character data type?
i) 2
bytes j)
1 bytes
k) 4 bytes
l) 8 bytes
50. What is the size of long integer data type?
m) 2 bytes
n) 1 bytes
o) 4 bytes
p) 8 bytes
51. Which will be the output?
for (i=1;1<5;i++)
{
if (i%2)
continue;
printf (“%d”, i);
}
a) 1 2 3 4 5
b) 1 3 5
c) 2 4
d) None of these
52. What will be the value of w?

a) xy +z
b) (x+y)z
c) (x’y+xy’)z
d) xy+x’y’+z
53. Which one of the following is primary constant?
a) Integer
b) Array
c) Structure
d) None of these
54. What will be the output?
void main ()
{
int x=9;
if (10)
printf (“%d”, ++x);
else
printf (“%d”, ++x);
}
a) 9
b) 10
c) 11
d) None of these
55. Fourth generation computer uses
a) VLSI
b) Simple integrated circuit
c) Semiconductor
d) Only transistor
56. What is the command in DOS to view the list of files located in current directory?
a) VIEW DIR
b) DIR
c) LIST
d) None of these
57. What will be placed in mantissa field in case of the number (11.1010)2?
a) 1010
b) 4
c) 11
d) 11.1010
58. What is the 2’s complement of (10011)2?
a) (01101)2
b) (01100)2
c) (01110)2
d) (01111)2
59. What is the 1’s complement of (1001111)2?
a) (0110000)2
b) (0110001)2
c) (0111010)2
d) (0111100)2
60. What is the 2’s complement of (10010)2?
(a) (14)10
(b) (12)10
(c) (14)8
(d) (01111)2
61. The function used to detect the end of file is?
(a) ferror()
(b) feof()
(c) fputs()
(d) fgetch()
62. De Morgans’s second theorem says that a NAND gate is equivalent to a bubbled ____ gate.
(a) AND (b) OR (c) XOR (d) none of these
63. A 32 bit microprocessor has the word length equal to
(a) 2 bytes (b) 4 bytes (c) 1 byte (d) 8 bytes
64. Which one is the right output?
int x = 9;
if(10)
printf(“%d”,++x);
else
printf(“%d”,x++);
(a) 9 (b) 10 (c) 11 (d) 12
65. In a C expression, how is a logical AND represented?
(a) @@ (b) ||
(c) AND (d) &&

66. Which will be the output?


#define SQR(A)A*A
main(){
{
int x=5;
int y;
y=4*SQR(x-3);
printf(“%d”,y);
}
(a) 8 (b) 64 (c) 16 (d) -52
63. members of a union use
a) different storage location
b) same storage location
c) no storage location
d) none of these

64. which of the following is conditional operators


a) ?:
b) if
c) 3.<
d) 4.&&

65. what will be the value of I and m after execution of following code?
int i=5,m;
m=i++;
(a) 5 and 6;
(b) 5 and 5;
(c) 6 and 5;
(d)6 and 6;

66. during storing of numbers in computer memory positive sign is denoted ny


a) 0
b) 1
c) +
d) -

67. which of the following is not used as secondary storage?


a) semiconduvtor memory
b) magnetic disks
c) magnetic drums
d) magnetic tapes

68. The union holds


a) one object at a time
b) multiple objects
c) both 1. and 2.
d) none of these

69. The function used to detect the end of file is


a) eof ()
b) ferror
c) fputs
d) fgtch

70. The output of


fact=1;
for(i=1;i<5;i++)
fact=fact*i;
printf(“%d”, fact);
is
a) 24
b) 5
c) infinite loop
d) none of these

71. The output of


void main()
{
int arr[6]={20,25};
printf(“%d %d”, arr[2], arr[3], arr[4]);
}
a) 0 0 0
b) 20 25 0
c) 25 0 0
d) none of these

72. Which one is the right output?


int x=9;
if(10)
printf(“%d”, ++x)
else
printf(“%d”,x++)
a) 9
b) 10
c) 11
d) 12

73. Which one is the right output?


char a[50]= “computer”;
printf(“%d”, strlen(a));
a) 9
b) 10
c) 8
d) 11

74. What is the range of unsigned short int?


a) 0 to 65535
b) 0 to 255
c) -128 to 127
d) None of these
75. In hexadecimal system D is equivalent to the number in
(a) 10 (b) 12
(c) 13 (d) 15
76. main()
{
int x=2, y=4;
x = x++ + ++y;
printf(“\n%d %d”,x,y);
}
What will be the output
(a) 3 5 (b) 7 5
(c) 8 5 (d) none of these
77. ASCII value of ‘B’ is
(a) 65 (b) 66
(c) 97 (d) none of these
78. main()
{
int n=8;
n=n >> 2;
printf(“\n%d”, n);
}
What will be the output
(a) 2 (b) 1
(c) 4 (d) none of these
79. Members of union use
(a) different storage locations (b) same storage location
(b) no storage locations (d) none of these
80. What is the output of the following C code?
#include < stdio.h >
void main()
{
double k=0;
for(k=0.0;k<3.0;k++);
printf(“%f”,k);
}
(a) 2.000000 (b) 4.000000
(b) 3.000000 (c) none of these

81. Number of variable to store a float variable is


(a) 8 bytes (b) 4 bytes
(c) 2 bytes (c) 6 bytes

82. A 64-bot microprocessor has the word length equals to


(a) 1 byte
b) 8 bytes
c) 2 bytes
d) 8 bytes
83. The correct syntax to send an array “array” as a parameter to function “func” is
(a) func(& array);
(b) func(array);
(d) func(*array);
(e) 1 func (array [size]);

84. The value of EOF is


(a) -1 (b) 0 (c) 1 (d) 10
85. Which of the following is a themselves a collection of different data types ?
(a) String (b) Structure
(b) Char (d) All of thise
86. int x = 2*3+4*5;
What value will x contain In the sample above?
(a) 22
(b) 26
(c) 46
d) 50.
87. “My salary was increased by 15% !”
Select the statement which will exactly reproduce the line of the text above.
(a) printf(“\”My salary was increased by 15/%”\ !\”\n”);
(b) printf(“My salary was increased by 15% !”\n”);
(c) printf(“My salary was increased by 15`%` !\n”);
(d) printf(“\”My salary was increased by 15% %!\”\n”);
[PART-B]
Short answer type questions each carrying 5 marks
Module I (Fundamentals of Computer)
1. a) What are the basic features of an algorithm? 1
b) What are the disadvantages of machine language and assembly language? 3+2

2. a) Convert to (17.25)10 binary.


b) What are 2’s compliment numbers? H o w d o u u s e t h e s y s t e m t o p e r f o r m ( 5 1 ) 1 0 -
( 2 7 ) 1 0 . What is signed magnitude number representation? What is its disadvantage?
1+1+2+1

3. a) Describe the functions of various units of a digital computer using a neat block

diagram. 5 Is it possible to realize a digital computer without using any primary

memory? 3

b) What will be the output?

4. What will be the output?

5. What will be the output?

6. Simplify: ((A+B)’.(B’+C)).((C+D’).(B+C’))’ and draw the simplified circuit.


Construct the circuit:
AB(A’+B)(B’+A) 5
7. Write a flowchart to find the sum of first n prime numbers, where n should be given by the user.
Write a flowchart to find the integers ranging from 100 to 200 and divisible by both 2 and 3. 3
8. (a) What is disadvantage of 1’s complement number. How it is overcome by 2’s complement. What
are the advantages of 2’s complement over 1’s complement? 3
(b) Perform the subtraction with the following binary numbers using 2’s complement:

11010 – 1101 [2+3]


9. What are the difference between compiler and interpreter? ½
What are 2’s complement of a number. 2
10. Convert the following numbers as indicated:
(a) Decimal 225.225 to binary
(b) Binary ( 1010110.11010)2 to octal and Hexadecimal
(c) Decimal 2AC5.D to binary

Perform the following operation: 8


Convert (100110101)2 to octal
Convert (1001010)2 to Hexadecimal
Convert (536)8 to hexadecimal
Convert (23.78)10 to binary
Convert (3AC)16 to Decimal
Convert (-496)10 to Octal
Convert (BEF2.09E)16 =()8
Subtract (7)10 from (17)10 in binary and add (-14) and 9 using 2's complement

11. Why are NAND and NOR gates called Universal gates? Explain with example. 2.5
12. If K bytes are required to store a number in hexadecimal number system, find how many bytes
will be required to store the number in binary number system? 5
13. If C1 and C2 are two computer languages, what do you mean by the statement "The level of
language C1 is higher than that of C2." Is it possible to convert the language of a particular level
into another language of other level? If so, how? If no, why? 3+2
14. Write a C program to compute the average of a few input quantities with minimum use of storage
variable, where the number of inputs is not known beforehand. 5
15. What is the significance of different levels of computer language? 3
Module – II(C Fundamental)
1. Write a C program to find the simple interest and total amount where the principle amount is 3000,
number of year is two and rate of interest is 10%.
2. What is type casting? What is automatic type conversion? 3
3. Explain unary operation with example.
4. Write short notes on the following:
a) Bitwise operator
b) Assignment operator
c) Logical operator
d) Increment and Decrement operator
5. Centigrade to Fahrenheit. 3
6. State the basic features of structured programming language. 3

Module III (Operators & Expressions)


1. What is logical operator?
2. Write a C program to calculate the sum of an A.P. where the range will be taken as input.
3. Write a complete C program to generate Fibonacci series. 3
4. What is a loop? Distinguish between while and do-while loop with an example.
5. Write a C program to find out the largest among n numbers taken as input. 5
6. Do the same using switch case and then compare switch case with the if-else statement.
7. Write a C program to implement 4 function calculator using Switch statement.
8. Explain unary, binary and ternary operators in C with example.
9. . What will be the output?
int main()
{
int a=8, b=10;
a=a++ + --b;
b=++b + a--;
printf(“%d %d”, a, b);
return 0;
}
10. Write a C program to check whether a given year is Leap year or not.
11. Write a complete C program to print prime numbers within a given range 10 to 100. 5
12. Write a C program to reverse a given number.

Module IV (Flow of Control)


1. Using conditional operator write a C program to find out the largest among two numbers taken as
input.
2. Write a C program to print the sum of the following series (upto n terms where n should be given by the
user)

Sum of n even numbers , where n is taken from user.


5 ACADEMY OF

Module V (Arrays & Pointers)

1. What is an array and subscript variable? 2 What condition must be satisfied by the entire element of
any given array? 2 (Ans. The entire elements of any given array have common characteristics. Then can be
characters, integers, floating-point numbers, structures, and so on. They must all, however, be of the same
type and the same storage class.)
2. Write a program in C to multiply two 2D matrices and display the resultant matrix. 5
Write a program which will create an n*n matrix. Transpose the matrix by passing it to a function. 5
3. Short notes on Array of pointers.
4. What is subscripted variable?
5. Explain “C does not support bound checking”.
6. Short notes on Pointer arithmetic
7. Allocate a two dimensional array dynamically using pointer in C language. 5
8. What is Dynamic memory allocation? Write down the difference between malloc() and calloc(). 3
9. Short notes on Void pointer & Null pointer.
10. Short notes on Dynamic memory allocation.
11. Sum of two matrices. 3
12. Explain call by value and call by reference by example and How they differ?. 5
13. Short note on pointer. 5
14. Briefly explain the arrange of n numbers in ascending orders. 5

16. Write a C program to check if a string taken as input is a palindrome or not without using string related
functions supported by the compiler.
17. What are compile-time and run-time array initialization?
18. Write a function to sort an array. Display the sorted array inside the main() function. 5

Module VI (Fundamentals & Program Structures)


1. Write a recursive function to find the summation of 1st n natural numbers and test the function by
calling from main function.
2. Write a C function to swap two integer data paased as rgument to a function and call the
function from the main() function. Don’t use any third variable. 5
3. What is function? What is the difference between iterative and recursive function? Explain with
a C program that calculates factorial of a number using iteration/ recursion take i/p from
keyboard. 5/10
4. What are function prototypes? When and where they are normally used? 5
5. What are the advantages of using function? What is the purpose of return statement?
6. Write down the difference between recursion and iteration. 5
7. What are auto, static , extern variable explain with example. 6
Short note on storage class. 5
8. Write a function prototype which accepts an integer, a float pointer, a string and a structure pointer as
parameters. 2

Module VII (Structure Union & Files)


ACADEMY OF
1. What is a file? Write the instructions in C for creating a file. 2+4
2. Write a C program to copy file fl.dat assuming fl.dat is available in your current working
directory. 9
3. What is File Mode? What are the types of file mode?
4. How to merge two files in c?
5. What is meant by following terms?
i. Nested structures
ii. Array of
structures 5

Give a typical example of use of each of them.

6. What is the difference between structure and union with example? 2/4

7. What is structure in C? How it is declared. 3


8. Compare array and structure with suitable example. 2
9. How do you access a structure variable through a structure pointer? Explain with example. 2
10. WAP to read a file and display its contents along with line number before each line. 7

[PART – C]

Long answer type questions each carrying 15 marks

Module I (Fundamentals of Computer)


1.
a) Describe in brief various parts of a digital computer with their working principle using a
neat block diagram. 3 Briefly discuss the function of memory unit (5) and discuss its various parts.
2 Write down the generation wise development of computer hardware. 2
b) What is the difference between digital and analog computer?
c) What is the binary equivalent of (324)10? Find the 2’s complement of (324)10 in binary form.
d) Distinguish between combinational and sequential circuit.
e) Find out the result of following subtraction and addition:
i) (10010)2+(11000)2
ii) (111110)2+(110001)2
iii) (11010)2-(11001)2 [without using 2’s complement]
iv) (11010)2-(10111)2 [using 2’s complement]
[5+2+1+1+2+4]
2.
a) What is an m u l t i p r o g r a m m i n g operating system? Write down the basic
features and operations of an operating system? 5
b) Write down the differences between compiler and interpreter? What is assembler? 2
c) Distinguish between ROM and RAM. Draw an AND gate and state the operation performed
by it. 1/5
d) Perform the following operations:
i) Convert (234)10 into its equivalent octal form
ii) Convert (904)10 into its equivalent hexadecimal form
iii) Convert (23.546)2 into its equivalent binary form
iv) Subtract (7)10 from (11)10 using 2’s complement
v) Find out the 1’s complement of (23)10
[1+3+2+1+2+1+5]

3.
a) What is a program? How it is different from an algorithm? Distinguish between flowchart and
algorithm. Explain with an example.
b) Write down the characteristics of an algorithm.
c) What is a flow chart? Find out the sum and average of all integers ranges from 50 to 100 and divisible by
both 2 and 3 using a flowchart. [5+5+5]
4.
a) What is main frame computer? How it is different from mini and micro computer? What are the
components used in an analog computer?
b) What is main memory? Compare main memory, secondary memory, cache memory and register set.
[1+2+2+2+8]
5. a) Explain two input Exclusive OR (XOR) gate using truth
table. 2 . 5 b) Simplify (A+B’).(A.C)+(AB’+A’C).(A+D)’ 4

Simplify: A’(A+B)+(B+A)(A+B’)
Represent the following expression using logic gates,
S=(AX+BY)+(CD+EF)
c) Convert:
i) (779)10 = (?)8
ii) (3 AF)16 = (?)8
iii) (34.465)10 = (?)2

(2AD)16=()2?
(11100111101)2=()16
(25.125)10=()2
(45.5675)10=()16 6 [4+5+6]

6. a) What is the difference between high level language and machine language? What is assembly
language? Does it platform independent? Justify your answer.
b) Explain ASCII and BCD. Find out the equivalent BCD form of (1335)10. What is extended ASCII?
[3+3+1+2+2+2+2]
7. Write down the DOS commands for the following:
i) Copy a file a.txt into another file b.txt present within the same
directory
ii) Display the current time and date
iii) Display all the files maintained in the current directory
iv) Create a new directory
v) Rename a file a.txt to x.txt [5 x 3]

8. a) Write short notes on the following each containing 5 marks:


i. Operating
system ii. CPU(Its
function and how it
perform them) 5
b) Draw a flowchart to find out the biggest number among three numbers taken as input. 5
[5+5+5]
c) Flowchart of sum of all perfect number within a given range. 5

9. Draw the flow chart to display the first n terms of the Fibonacci series. The first two terms of the series are
respectively 0 and 1. The nth term of the series F is defined as Fn=Fn-1+Fn-2 5
10. Write an algorithm to find the sum of the first n numbers, where n should be read from the user. 5
11. Write an algorithm to find the largest among numbers, taken from the user.

Module II (C Fundamental)

1. a) What are the different data types in C?


b) What is the difference between signed int and unsigned int?
c) What do you mean by C token? [5+5+5]

2. a) Write a C program to swap the values of two variables with and without using the third variable.
b) What is the difference between expression and statement?
c) Discuss Escape Sequence in C. [5+5+5]
3. a) Give a numerical example of using modulus operation %.
b) What will happen if % is used between two float variables?
c) How can you evaluate (-b +√(b2- 4ac)\2a) in the C language? [5+5+5]

4. a) Explain precedence and associativity of operators with suitable examples.


b) Distinguish between i++ and ++i with suitable examples.
c) Write a complete C program to convert a given temperature in Fahrenheit scale to its equivalent
Centigrade scale.
[5+5+5]
Module III (Operators & Expressions)

1. Using conditional operator write a C program to find out the largest among two numbers taken as
input.
2. Write a C program to calculate the gross salary (sum of basic salary, DA, HRA) of an employee where
DA is 35% of basic salary, HRA is 15% of basic salary and basic salary is taken as input.
3. Write a C program to find the simple interest and total amount where the principle amount is 3000,
number of year is two and rate of interest is 10%.
4. What is ternary operator? Explain with an example. 2+1
5. What is type casting? What is automatic type conversion? 3
6. Explain unary operation with example. 5
7. Write a function in C to swap the values of two variables without using a third variable.
8. Explain bitwise operators. What is the difference between i++ and ++i? 5
9. What are the types of constants used in C?
10. Write short notes on the following:
e) Bitwise operator
f) Assignment operator
g) Logical operator
h) Increment and Decrement operator

Module IV (Flow of Control)


1. Write a C program to print the following:
1
1 2
2 3 4
3 4 5 6
4 5 6 7 8

2. Write a complete C program to generate Fibonacci series.


3. What is a loop? Distinguish between while and do-while loop with an example. 5
Comparative study between for, while and do-while loop. 5
4. Write a C program to find out the largest among three numbers taken as input using if-else statement.
5. Do the same using switch case and then compare switch case with the if-else statement.
6. Write a complete C program to print the following:
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
7. Write a complete C program to print the following:
*
* *
* * *
* * * *
* * * * *
8. Write a complete C program to print the following pattern for n number of rows:
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * *

9. Write a complete C program to calculate the G.C.D. of three numbers taken as input.
10. Differentiate between “break” and “continue” with an example. 5
What is the utility of break statement in loop? Give an example. How is break statement different from exit(). 4
11. Write a complete C program to check whether a number if prime or not. 5
12. Write a C program to evaluate the following summation series where the range will be taken as input

from the keyboard.

13. Write a C program to print the sum of the following series (upto n terms where n should be given by the

user)

14. Draw a flowchart to find out the biggest number among given three numbers.
15. Write a C program to implement 4 function calculator using Switch statement.
16. Explain unary, binary and ternary operators in C with example.
17. What will be the output?
int main()
{
int a=8, b=10;
a=a++ + --b;
b=++b + a--;
printf(“%d %d”, a, b);
return 0;
}
18. Use ternary operator to find out the minimum among three numbers. 3
19. Write a C program to check whether a given year is Leap year or not.
20. What is a loop? Distinguish between while and do-while loop with an example. 3
21. Write a C program to reverse a given number.
22. Write a C program to print the following:
1
2 3
4 5 6
7 8 9 10

23. Write a C program to print the following pattern (till n rows, where n is taken as input)
1
2 2
3 3 3
4 4 4 4

24. Write a complete C program to calculate the G.C.D. of three numbers taken as input.
25. Write a C program to print the following star orientation till n rows where n is the i/p:
*

* *

* * *

* * * *
Write a C program to print the following pattern 5
1
232
34543
4567654

Write a C program to print the following pattern 5


*
***
*****
*******

Write a C program to print the following pattern 5


G FE D C BA
FE D C BA
EDCBA
DCBA
CBA
BA
A

26. Write a complete C program to print prime numbers within a given range.
27. Write a C program to check whether a number is strong or not.

28. Explain the output of following program: 3+2


a.
void main(){
int i,j;
for(i=1;i<=2;i++){
for(j=1;j<=2;j++){
if(i==j) continue;
printf("%d %d",i,j);
}
}
}
b.
void main(){
int n=8;
n=n<<2;
printf("n= %d",n);
}

29. Draw the pattern


1
12
234
3456
45678

Module V (Arrays & Pointers)

1. Write a program to input a n X n matrix and print the maximum element of the matrix.
2. (a) What is subscripted variable?
(b) Write a complete C program to convert a decimal number consisting of arbitrary
number of digits into its binary form using 1 -D array.
(c) Write a complete C program to find out the Trace of a square matrix [Trace means the sum of
Principal Diagonal Elements].

3. (a) How can you represent a string using the C programming language? 1
(b) Name any five string functions whose prototype is defined in the string.h header file.
Explain the work of any two of them. 5
(c) Write a C program to find the number of vowels and consonants in a line text. 4
(d) Write a C program to convert all lower case alphabets to upper case alphabets, a line of text 5
4. Palindrome string check. 5
5. Explain C doesn’t support bounds checking. 2
6. What is the difference between a character array and a string? 5
7. Write a function which will split a string into two halves and return the result as an array of string. 6
Module VI (Fundamentals & Program Structures)

1. Write a function (recursive/non-recursive) power (a, b) that can calculate ab for any floating
a and positive integer b. Invoke this function into main function to calculate xn.. 2
2. Write a recursive function to find the summation of 1st n natural numbers and test the function by
calling from main function.
3. Write a C function to find the cube of a number and use this function in main () function to evaluate
x3+ y3+ z3, where x, y, z are read through standard input device.
4. Write a function to find out the real roots of a quadratic equation using user defined
function quad(). 7
5. Write a C program to find out the GCD a n d L C M of two numbers using recursion or
iteration. 5
6. What is recursion? Explain recursion with an example. What are the advantages and
disadvantages of recursion? 2+3

Module VII (Structure Union & Files)

1. Define a structure called cricket that will describe the following information: 9
i) Player Name
ii) TeamName
iii) Batting Average
Using cricket declare an array player with 50 elements and write a C program to read the
information of all the 50 players and print the name of the player having the highest batting
average.
2. a) What is structure in C? Why it is used? How is it
declared? 2
b) Declare a structure having members of appropriate type
Branch
Name
Roll No
Marks in 8 subjects
Write a C program to create an array of 30 structure variables and read all the members of each
variable. 9

c) Create a structure named books which has the following variables:


Name, id, price, subject
Write a program which will take details about 'n' books from the user.
Write a function which will display the names of the books which fall within a given price range. Also write a
function which will display the books for a certain given subject.

3. (a) Explain with suitable example, the difference between structure and union in a C program.
(b) Suppose you have to create and maintain a Record Book of your company. Record Book
consists of the following fields: (i) Employee's Name (ii) Id Number (iii) Salary Amount (iv)
Designation. How do you create and maintain this Record Book for 150 Employees of your
organization if your management asks to see the salary of any particular employee? 6
(c) Explain Call-by-Value and Call-by-Address with examples. 6

4. Write a C program that will receive a file name and a line of text as command line arguments and
write the text to that file. 7

5. Can we read from a file and write to the same file without resetting the file pointer? Justify.
6. Create a structure to specify data on students give below:
Roll Number, Name, Department, Course, and Year of
admission. Assume that there are not more than 450 students
in collage,
Write a program to print names of all students who joined in a particular year. 7
7. (a) Write a C program to create a copy of a text file "file 1.txt”" into another "file 2.
txt”. 9 (b) What is the difference in opening a file in "r+" and "w+" modes? 3
(c) What do the fprintf( ) and fread( ) functions do?
3
8. Write a C program to accept a string as a command line argument/without command line argument and hence
find its length without using strlen(). 9

[PART – D]

Module I (Fundamentals of Computer)


1. Discuss the functions of operating system.
2. What are the different types of operating system?
3. What do you mean by assembler, compiler and interpreter?
4. Differentiate between high-level, middle-level and low-level language.
5. What is assembly language? Discuss its advantages.

Module II (C Fundamental)

1. Describe the four basic data types. How could we extend the range of the values they represent?
2. What is an unsigned integer constant? What is the significance of declaring a constant unsigned?
3. What do you mean by declaration and definition of a variable?
4. What is the importance of flowchart?
5. What is the use of ASCII?
6. What are escape sequence characters? What is the purpose of use them?
7. What are the return type and return value of printf( ) and scanf( ) functions?
8. What do you mean by overflow and underflow of data?

Module III (Operators and Expressions)

1. Write a C program to test whether a no. is power of 2 or not.


2. Write a C program to check whether a no. is even or odd without using % operation.
3. Write a C-program which does the addition of two integers without using ‘+’ operator.
4. Write a C-program to find the smallest of three integers without using any of the comparison
operators.
5. Find the maximum & minimum of two numbers in a single line without using any condition & loop.
6. Is it possible to use %( modulo division operator) on floating point data?
7. Explain mixed mode arithmetic with a example.
8. Explain the output of the following code.
int main()
{
int a=8, b=10;
a=a++ + --b;
b=++b + a--;
printf(“%d %d”, a, b);
return 0;
}
9. Explain precedence and associativity with an example.

10. Explain the output of the following program.


Question Page 1
#include<stdio.h>
int main()
{
int i=-3, j=2, k=0, m;
m = ++i && ++j || ++k;
printf("%d, %d, %d, %d\n", i, j, k, m);
return 0;
}
11. Explain the difference between logical AND(&&) and bitwise AND(&) operator.
12. Explain the output of the following program.

#include<stdio.h>
int main(){
int x=55;
printf("%d, %d, %d\n", x<=55, x=40, x>=10);
return 0;
}

13. Consider the following code:


void main()
{
int i=0, j=1, k=2, m;
m = i++ || j++ || k++;
printf("%d %d %d %d", m, i, j, k);
}
Explain the output of the above code.
14. Explain the output of the following program?
void main()
{
int a, b, c, d;
a = 3;
b = 5;
c = a, b;
d = (a, b);
printf("c=%d d=%d", c, d);
}
15. Explain the output of this program on an implementation where int occupies 2 bytes?
#include <stdio.h>
void main()
{
int i = 3;
int j;
j = sizeof(++i + ++i);
printf("i=%d j=%d", i, j);
}
Module IV (Flow of Control)

1. How to print number from 1 to 100 without using conditional operators?


2. Explain how many times "VIRAT" is get printed
#include<stdio.h>
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x < 5)
continue;
else
break;
printf("VIRAT");
}
return 0;
}
3. Explain the necessity of different loops?
4. Explain the difference while and do-while loop with an example 5
5. Write a complete C program to print prime numbers within a given range.
6. Differentiate between “break” and “continue” with an example. 3
7. Explain unary, binary and ternary operators in C with example.

Module V (Arrays & Pointers)

1. Do array subscripts always start with zero? Explain.


2. Write a program which will store values into an array from a text file and calculate the average
value.
3. What is the difference between array_name and &array_name?
4. Is it valid to address one element beyond the end of an array? Explain
5. Write a program which will check whether a square matrix is symmetric or not?

6. Write a program which will check whether a square matrix is lower triangular or not?
7. Write a program which will check whether a square matrix is upper triangular or not?
8. Write a program which will find out trace (sum of all diagonal elements) of a square matrix.

9. What is array of pointers? Explain with an example. What is the relationship between array and
pointers? 5
10. What is pointer to an array? Explain with an example.
11. With an example show the passing of 2D array into a function.
12. Why a[5] == 5[a]? Explain.
13. What do you understand by const pointer? Explain with an example
14. Why we can not add two pointers?
15. Why are pointers different sizes on different machines?
16. Can I convert a pointer to an ordinary number? Give your logic.
17. Does C use the sizeof operator when it is adjusting pointer arithmetic? Give your logic.
18. Is it possible to write scanf statement without ‘&’ operator. Give your logic with an example.
19. What is the output? 3
void fun(int *i,int *j);
main(){
int i=5,j=2;
fun(&i,&j);
printf("\n%d %d",i,j);
}
fun(int *i,int *j){
*i=*i* *i;
*j=*j* *j;
}

Module VI (Functions & Pre-processor)

1. What are the advantages of using a function?


2. What are the function prototypes?
3. Write a C program to count the number of vowels in a string.
4. Write short note on “Pointer to Function” and “Function returning a Pointer”.
5. Write a function(recursive and non-recursive) mypower(a,b) which will calculate ab for any
floating value a and integer value b.
6. What is the purpose of return statement?
7. What is Static and Dynamic memory Allocation? Give suitable example.
8. Explain the role of C preprocessor. 2

9. How macro differs from a constant value in C? 4


10. Using ternary operator write a macro to find out the absolute value of a number. 5

11. What is the output:


#define SQ(x) x*x
Printf(“%d”,sq(4+2));

12. Short note on macro 5

Module VII (Structure Union & Files)

1. Explain how members of a union are accessed using a program code.


2. Write a program to add and subtract the height of two different persons.
3. Described about nested structure.
4. Explain the utility of type def key words in structure.
5. In which application union can be useful?
6. Is it possible to create an array of structure? Explain with the help of a example.
7. Explain with an example how structure is initialized.
8. “Structure declaration reserves memory for the structure”, comment on this statement with valid
justification.
9. Write a program to calculate the distance between two given co-ordinates.
10. Describe self referential structure.
11. Explain with example union inside a structure.
12. How a function can access the members of a structure.
13. Explain with example local and global structure.
14. Write a program to define a union and a structure both having exactly the same member. Using the
size of operator print the size of structure of structure variable as well as the union variable.
15. Write the functions name and syntax to read data from a file.
16. Explain fseek() function.
17. Explain the term stream.
18. Why should you close a file after it is used?
19. Under which circumstances does the function fopen() fail.
20. What is the impact of fclose() on buffer data.
21. Differentiate between gets() and fgets() functions.
22. Where can the function ftell() be used?
23. Why do we need fflush()?
24. Differentiate between fscanf() and fread()?
25. How will you check for EOF when reading a file?

Enum
1. Enumerated data type. 5

Potrebbero piacerti anche