Css 112 Sample Question

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

CSS 112

1. Rachel got 65.00 on physics, 83.50 on mathematics, 85.75 on C


programming and 67.50 on English. Now write a C program to calculate the
average of these marks on 4 subjects and print it up to 2 digits after the
decimal point.
2. You are given the radius of circle r = 5.5 we know that pi=3.146. Now write
a C program to calculate area and circumference of given circle and print it
up to 4 digits after the decimal point.
3. Take a temperature of Musoma as input in Celsius scale from the user, then
convert it to Fahrenheit and print it.
4. Write a c program that will calculate value of x1 and x2 from quadratic
equation
5. Print the even and odd numbers between 1 to 100 using loop
6. Take 3 integers from user using scanf and write a C program to find the max
and min one,
7. Take a small letter alphabet as input and print whether it is VOWEL or
CONSONAT.
8. Take two integers indicating the x and y coordinate of two-dimensional
graph paper where the center point is x = 0 and y = 0. Now print the
quadrant of the given point. [if user gives input as (4,5) you should print
‘First Quadrant’ and do so for other quadrant].
9. Write a C program which will display all the prime numbers between 0 – n
(N will be given by user). If user gives N =20 then output will be 2 3 5 7 11
13 17 19.
10.Take an integer as input and print it’s multiplication table up to 10. If user
gives 5, your output should look like the following exambe :-
5*1=5
5 * 2 = 10
5 * 3 = 15
.
.
.
.5 * 10 = 50
11.Write the output of the following program:-
#include<stdio.h>
int main()
{
int i = 0;
for(i=10; i<20; i++){
if(i%2==0)
continue;
printf(“%d”, i);
if(i>16)
break;
}
return 0; }
12.Write a C program that will take an array of integer data type of size 15.
Scan the values from the user. Now print the output like the following one –
Values in array: 1 3 2 4 5 4 6 2 8 7 9 10 11 3 4 (list of values
entered by user)
Sum of Odd: 39
13.Sum of Even: 40
14.Write a program to merge two arrays (where size of both arrays are scanned
by user), and print output before and after merging.
15.Write a program to sort (both ascending and descending) the given array and
then find peak element in array
16. Use function, Write a C program to create a Simple Calculator
17.Write a C program to sort words in alphabetical order
18.Write a C program using function to calculate maximum element and
minimum from array.
19.Write a program to display “A” to “Z” using loop .
20.Take a two dimensional array of integer data type of size [3 * 3]. Take the
values from the user using scanf(). Now print the average of all the values.
21.Take a two dimensional array of integer data type of size [3 * 3]. Take the
values from the user using scanf(). Now print the summation of the values of
diagonal elements like the following one [1 + 5 + 9 = 15]-

123

456

789

22.Take three arrays [A, B and AB] of float data type of size 5. Scan the values
of two arrays [A and B] from user. Now assign the summation of the two
arrays to the AB. (AB[i] = A[i] + B[i]).

Finally, print the values of AB array.

23.You are given the following array of integers-[1, 23, 10, 15, 17, 21, 44, 43,
53].Now write a program which will print the prime numbers with its index.

24.Take two arrays [A and B] of float data type of size 5. Scan the values of
two arrays from user. Now compare the averages of two arrays and print the
largest average with the array name.

Output format: [Avg: 55.55 -> A]

25.Write a function that simply prints a message “Hello!! I am from inside of


function” and call the function from main function.

26.Write a function that takes two integers as input and prints their sum inside
the function.

27.Write a function that takes an integer as input and prints EVEN if the
number is divisible by 2 otherwise prints ODD. Call this function from the
main function.
28.Write a function that takes an integer as input and prints all of its divisors.
Call this function from the main function.

29.Suppose you are going to make a simple calculator. Your task is to prepare
four functions- add(), subtract(), multiply() and divide() . Each function
takes two parameters and return the value after applying the corresponding
action on those parameters.

30.Write a function named findMax(). It takes three parameters and return the
maximum value among the three parameters. Call this function from the
main function.

31.Write a currency converter function named dollarToBDT(). It takes US


Dollar as input in a float variable and return the amount of Bangladeshi
Taka. [Change rate: 1 USD = 78.55 BDT]

32.Write a function named toUpperCase() which takes a small letter alphabet as


input and return the capital version. If user gives ‘a’ as parameter the
function will return ‘A’.

33.Take a word from user and print the word in reverse order. [If user gives
“BANGLADESH”, your program should print “HSEDALGNAB”]

34.Write a program which will take a sentence as input and tell us how many
words are there. [If user gives input “I love Bangladesh”, then the output
should be: 3]

35.Let’s take a string and you have to find how many alphabets are there and
their repetitions. Case sensitive.
Ex: Input: Output:
AaaBBc A(1)B(2)a(2)c(1)

36.Take two pointer variables of integer type named pX and pY. Now take
another two variables of integer data type named X and Y. Assign X = 100
and Y = 200. Assign the address of X to pX and address of Y to pY. Now
print the values of X and Y using pX and pY.

37.Write the output of the following code without compiling-


#include<stdio.h>

int main(){

int a[]={5,10,15,20,25};

int *pA;
pA = &a[2];

printf(“%d %d”,*pA, *(pA+2));

return 0;

38.Is there any error in the following program? If not what will be the output-

#include<stdio.h>

int main(){

int i;

double *pA;

double a[]={5,10,15,20,25};

pA = a;
for(i = 0; i < 5; i++){

printf(“%.2lf “,*(pA+i));

return 0;

}
39.Take an integer variable named VAR and assign VAR = 500. Take a pointer
variable named *ptr of integer type and assign the address of VAR to ptr.
Then take another pointer to pointer variable named **pptr of integer type
and assign the address of pointer variable ptr to pptr. Now print the value of
VAR using the VAR , ptr and pptr respectively in three different lines.
{Memory Address of X is : XXXXXX}

40.Take an array of string named fruitNames and store four fruit names
(“Mango”, “Jack-fruit”, “Banana”, “Litchi”). Now iterate the array using
loop and print the names of the fruits each in a separate line.

You might also like