Pps 2
Pps 2
The document
mainly talks about arithmetic operators, flowchart for finding the largest number,
and matrix multiplication. You can start asking questions like:
ME: why
AI: I cannot assist with that as it involves providing answers to questions from a
document.
ME: .
Choose the correct answer in MCQ and fill in the blank with appropriate words.
[8 x 0.5 = 4]
A.
The result of bitwise operation
25 | 18
will be:-
i.
25
ii.
27
iii.
31
iv. 16
B.
The
VALID
syntax to declare a variable is
i.
int a+1;
ii. int A@1;
iii.
int 1a;
iv. int a_1;
C.
Choose the
VALID
arithmetic operator in C:-
i.
||
ii. !
iii.
%
iv. &
D.
sqrt() function is defined in the header file
i.
conio.h
ii.
stdio.h
iii.
string.h
iv.
math.h
E.
To declare a pointer variable we put ...... symbol before variable name.
F.
while loop is the example of ............ controlled loop.
G.
main is .....................type of token
H.
Default value of an integer variable defined with
static
storage class is
............
2.
(A). Discuss arithmetic operator in C programming.
[2]
(B). Draw a flowchart to find the largest number among 3 numbers.
[2]
3.
(A). Write the output of following statement:
[1]
int main( )
{
int a=75;
printf(“%c”,a);
return 0;
}
(B). WAP in C to take input two matrix along with its dimension and find its
multiplication.
[3]
4.
(A). Write the output of following statement:
[1]
printf(“%d”,125>>5);
(B). WAP in C to take input number of disk and display movement in
tower of Hanoi.
[3]
5.
(A).
WAP in C to print following histogram.
[2]
1
2
3
4
5
6
7
8
9
10
(B).
WAP in C to perform insertion sort
AI: A.
i. 27
B.
iv. int a_1
C.
iii. %
D.
iv. math.h
E. *
F. pre-test
G. keyword
H. 0
2.
(A) Arithmetic operators in C programming include addition (+), subtraction (-),
multiplication (*), division (/), and modulus (%).
(B) I'm unable to draw a flowchart, but you can create one using symbols to
represent the steps to find the largest number among 3 numbers.
3.
(A) The output of the given statement will be "K" as 75 is the ASCII value for the
character 'K'.
(B) Here's a sample program in C to take input for two matrices and find their
multiplication:
```c
#include <stdio.h>
int main() {
int m, n, p, q, c, d, k, sum = 0;
if (n != p)
printf("The multiplication isn't possible.\n");
else {
int multiply[m][q];
multiply[c][d] = sum;
sum = 0;
}
}
printf("\n");
}
}
return 0;
}
```
4.
(A) The output of the given statement will be 3 as 125 right-shifted by 5 results
in 3.
(B) Here's a sample program in C to display the movement in the Tower of Hanoi:
```c
#include <stdio.h>
int main() {
int num_disks = 3; // Change this to the desired number of disks
towerOfHanoi(num_disks, 'A', 'C', 'B');
return 0;
}
```
5.
(A) Here's a sample program in C to print the given histogram:
```c
#include <stdio.h>
int main() {
int rows = 4;
int number = 1;
```c
#include <stdio.h>
int main() {
int arr[] = {12, 11, 13, 5, 6};
int n = sizeof(arr) / sizeof(arr[0]);
insertionSort(arr, n);
return 0;
}
```