Lab-Questions 2
Lab-Questions 2
2. (a) Write a program to enter a character by using getchar (), convert it into opposite (small to capital
and capital to small) and use putchar () function to display result.
(b) Write a C program to insert an element at ith index of an array
3. (a) Write a program to enter your year of birth and check whether the year is leap year or not and also
check how many leap years occurs after your birth
(b) Write a C program to Delete the element in pth position of an array
4. (a) Write a program to display numbers from 20 to 1 in reverse order and also find their sum.
(b) Write a C program to find total number of alphabets, digits or special character in a string
5. (a) Write a program to find out the Armstrong numbers from 0 to 999 range.
(b) Develop a program to read ‘N’ random numbers in an array and Find the prime and non-prime
numbers and move them into separate arrays named as prime [] and Non-prime [] respectively.
6. (a) Write a program to enter three-digit number and check whether number is palindrome or not. Palin-
drome is the number which will be same on reversing it.
(b) Write a c program to Print the contents of a 2D array right-diagonal order.
8. (a) Write a program to accept a number N as input from the user and print the following pattern
*******
* *
* *
* *
* *
* *
*******
(b) Develop a C program to compute factorial of a number with and without recursion
1
9. (a) Write a C program to read salary of an employee and print grade.
Salary Grade
>= 30000 A
20000 − 30000 B
10000 − 20000 C
< 10000 D
(b) Write a C program to read 4 × 4 matrix and check sum of middle row is equal to sum of middle
column.
10. (a) Write a C program to read a number and check if it is a positive, negative, Even, Odd, Prime number
or zero.
(b) Write a program to find and print the maximum and minimum element of each row of a matrix
11. (a) Write a C program to find the sum of perfect numbers from the N natural numbers
(b) Develop C program to find the frequency of each character in the string
12. (a) Write a program in C to read N numbers (any numbers by user choice) from the keyboard and find
the prime numbers among them.
(b) Develop C program to Check whether the given string is a palindrome or not without using library
functions
13. (a) Write a C program to make such a pattern as a pyramid with a star
(b) Write a C program to count total number of words and sentences in a string
14. (a) Write a program in C to display the n terms of a harmonic series and their sum.
1 1 1 1
1+ + + + + . . . . + n1 terms
2 3 4 5
(b) Write a C program to find the frequency of characters in a string. Identify the highest frequency
character.
15. (a) Write a C program to find the ‘Perfect’ and ‘Prime’ numbers within a given number of ranges.
(b) Write a C program to remove all repeated characters from a given string.
16. (a) Write a Program to add user entered numbers until the user enters zero.
(b) Write a C program to find first occurrence of each word in a given string.
2
17. (a) Write a program to sum the user entered only even numbers until the user enters zero or any
Character.
(b) Write a program to accept a string as input and count the number of vowels in it.
18. (a) Write a C program to swap two numbers using bitwise XOR operator and without using third temp
variable.
(b) Write a program to accept 2 strings as input and concatenate them into a third string and print the
third string.
19. (a) Write a C Program to input the two positive numbers from the user and perform the addition
operation on first number with Right shift by two units and second number with left shift by one
unit.
(b) Write a C program with user defined function to swap two strings without using library function.
20. (a) Develop C program for calculating the charge for transporting the luggage service offered by Indian
railways as per the constrains given below.
Upto 25 kg, charges were Rs. 0.30 per kilometer /kg.
Beyond 25 kg, Rs.0.5 per kilometer /kg.
If total bill more than 1000/−, then 3% discount applicable.
(b) Write a C program to display all perfect numbers between 1 to N by using user defined function.