Lab assignment
1. WAP to ask the user the age and determine if he can vote
or not, the condition is age should be greater or equal to
18.(if else)
2. WAP to ask the user to enter the temperature in degree
celcius and based on the table below display the
message.(if else ladder)
Temperature Message
<18 COLD
>=18 and <=25 MILD
>25 HOT
3. WAP to enter and ask the user for two numbers a and b
and then tell the user which one is greater. (if else ladder)
4. WAP to check whether the year is leap of not so if a year
is divisible by 4 it is a leap year. Futher it should be
divisible by 100 and also 400. Eg:1600 is a leap year but
1500 is not. (nested if else)
5. WAP to calculate the following electricity bills in Nepal
according to the table:
Upto 20 units Rs. 80 per unit
From 21 to 250 units Rs.7.30 per unit
Over 250 units Rs.9.90 per unit
Ask the user to input the units consumed.
6. Create a program to check if a character entered by the
user is a vowel(consider only lowercase vowels.)
7. WAP to find the largest of three numbers. (if else ladder)
8. WAP to check if a number is three digits even numbers.
(if else ladder)
9. WAP to ask the user for a number from 1 to 7 and then
tell the respective day using switch case)
10. WAP to check whether a number entered by the user
is odd or even using switch case.
11. WAP to check whether an alphabet is vowel or
consonant using switch case.
12. WAP to print the odd number from 1 to 20 using loop.
13. WAP to generate the multiplication of a number given
by user.
14. WAP to check a number entered by the user is prime
or not
15. WAP to ask for five numbers and sum of them using
loop.
16. WAP to print the number from 1 to 10 in reverse order.
17. WAP to print the number from 1 to 10 without 5 in it.
18. WAP to read 10 number from the user and find the
average. (while loop)
19. WAP to print numbers from 1 to 100 which is divisible
by 7.
20. WAP to print multiplication program from 1 to 10.
(nested loop for)
21. WAP to generate all the prime numbers up to the
numbers provided by the user. (nested loop for)
22. WAP to print the following patterns.
a. * b. ***** c. 1
** **** 2 2
*** *** 3 3 3
**** ** 4 4 4 4
***** * 5 5 5 5 5
d. 1 e. 15 14 13 12 11
2 3 10 9 8 7
4 5 6 6 5 4
7 8 9 10 3 2
11 12 13 14 15 1
f. * g. *
** **
*** ***
**** *
***** **
***
****
h. * i. ******* j. 1
*** ***** 2 3
***** *** 4 5 6
******* * 7 8 9 10
11 12 13 14 15
23. WAP to generate all the prime number up to the
number provided by the user. (nested loop while)
24. WAP to ask the user to enter his/her name and then
print welcome name. (array)
25. WAP to ask the user to enter marks in 8 subject and
then calculate the total marks.
26. WAP to ask the user to input 10 numbers and store it
in an array called num, now ask the user to enter a
number and search it in the array.
27. There are two arrays arr1 and arr2 with 10 elements
each. WAP to create a new array that holds the sum of
the elements of those two arrays with the position wise.
28. Declare a 2D array called num of size 4*3. Now WAP to
ask the user input all the elements and display it.
29. Given there are 2 array arr1 and arr2 with dimension
of 4*4. Now create new array arr3 which holds the sum
of consecutive elements.
30. WAP to multiply two numbers mat A and mat B of size
2*3 and 3*4 respectively. The result should be calculated
in a res matrix of adequate size. Initialize mat A and mat
B by declaring number of your size.
31. Example program of strlen().
32. WAP to reverse a string.
33. WAP to capitalize the letter of string.
34. WAP to print the characters and ACSII value of capital
A to Z and small a to z.
35. WAP to reverse a number.
36. WAP to ask the user to enter two numbers a and b
then without using math.h calulate a to the power b.
37. Example program of pass by value.
38. Example program of call by reference.
39. WAP to ask the user for their name and number n. Now
write a function where you passed the name and n as
argument and print the name n times inside the function.
You should call this function from main method.
40. WAP with a function called findlength() where the
function takes a strings as an argument and returns its
length without using strlen().
41. WAP with its function to sort the given array of
integers in ascending number.
42. WAP to pass two arrays (matrix) of size a*b and then
display sum of these two arrays using function.
43. WAP to ask a number from user and then calculate the
sum till that numbers using recursive function.
44. WAP to print the Fibonacci number using recursive
function.
45. WAP a recursive function to print out odd numbers up
to n terms.
46. WAP to count the numbers of digits in a given numbers
using recursive function.
47. WAP to calculate ab using recursive function.
48. WAP to multiply two matrices mat A and mat B of size
2*3 and 3*4 respectively. The result should be calculated
in a res matrix in a adequate size. Initialize the matrix
with declaration. You are only allowed to use pointer to
array while doing operations.
49. Example program of function pointer.
50. Example program of malloc.
51. Example program of calloc.