0% found this document useful (0 votes)
6 views

PROGRAMMING QUESTIONS

The document contains a comprehensive list of C programming exercises covering various topics including conditional operators, bitwise operations, control structures (if-else, switch-case), loops, recursion, arrays, matrices, and string manipulation. Each section includes multiple programs aimed at solving specific problems, such as finding maximum values, checking for even or odd numbers, performing arithmetic operations, and manipulating data structures. This extensive collection serves as a resource for practicing and mastering C programming concepts.

Uploaded by

harshrastogi2020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

PROGRAMMING QUESTIONS

The document contains a comprehensive list of C programming exercises covering various topics including conditional operators, bitwise operations, control structures (if-else, switch-case), loops, recursion, arrays, matrices, and string manipulation. Each section includes multiple programs aimed at solving specific problems, such as finding maximum values, checking for even or odd numbers, performing arithmetic operations, and manipulating data structures. This extensive collection serves as a resource for practicing and mastering C programming concepts.

Uploaded by

harshrastogi2020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

Write a C program to find maximum between two numbers using conditional operator.

Write a C program to find maximum between three numbers using conditional operator.
Write a C program to check whether a number is even or odd using conditional
operator.
Write a C program to check whether year is leap year or not using conditional
operator.
Write a C program to check whether character is an alphabet or not using
conditional operator.

Write a C program to perform input/output of all basic data types.


Write a C program to enter two numbers and find their sum.
Write a C program to enter two numbers and perform all arithmetic operations.
Write a C program to enter length and breadth of a rectangle and find its
perimeter.
Write a C program to enter length and breadth of a rectangle and find its area.
Write a C program to enter radius of a circle and find its diameter, circumference
and area.
Write a C program to enter length in centimeter and convert it into meter and
kilometer.
Write a C program to enter temperature in Celsius and convert it into Fahrenheit.
Write a C program to enter temperature in Fahrenheit and convert to Celsius
Write a C program to convert days into years, weeks and days.
Write a C program to find power of any number x ^ y.
Write a C program to enter any number and calculate its square root.
Write a C program to enter two angles of a triangle and find the third angle.
Write a C program to enter base and height of a triangle and find its area.
Write a C program to calculate area of an equilateral triangle.
Write a C program to enter marks of five subjects and calculate total, average and
percentage.
Write a C program to enter P, T, R and calculate Simple Interest.
Write a C program to enter P, T, R and calculate Compound Interest.

BITWISE EXERCISE

Write a C program to check Least Significant Bit (LSB) of a number is set or not.
Write a C program to check Most Significant Bit (MSB) of a number is set or not.
Write a C program to get nth bit of a number.
Write a C program to set nth bit of a number.
Write a C program to clear nth bit of a number.
Write a C program to toggle nth bit of a number.
Write a C program to get highest set bit of a number.
Write a C program to get lowest set bit of a number.
Write a C program to count trailing zeros in a binary number.
Write a C program to count leading zeros in a binary number.
Write a C program to flip bits of a binary number using bitwise operator.
Write a C program to count total zeros and ones in a binary number.
Write a C program to rotate bits of a given number.
Write a C program to convert decimal to binary number system using bitwise
operator.
Write a C program to swap two numbers using bitwise operator.
Write a C program to check whether a number is even or odd using bitwise operator.

IF AND ELSE EXERCISE

Write a C program to find maximum between two numbers.


Write a C program to find maximum between three numbers.
Write a C program to check whether a number is negative, positive or zero.
Write a C program to check whether a number is divisible by 5 and 11 or not.
Write a C program to check whether a number is even or odd.
Write a C program to check whether a year is leap year or not.
Write a C program to check whether a character is alphabet or not.
Write a C program to input any alphabet and check whether it is vowel or consonant.
Write a C program to input any character and check whether it is alphabet, digit or
special character.
Write a C program to check whether a character is uppercase or lowercase alphabet.
Write a C program to input week number and print week day.
Write a C program to input month number and print number of days in that month.
Write a C program to count total number of notes in given amount.
Write a C program to input angles of a triangle and check whether triangle is valid
or not.
Write a C program to input all sides of a triangle and check whether triangle is
valid or not.
Write a C program to check whether the triangle is equilateral, isosceles or
scalene triangle.
Write a C program to find all roots of a quadratic equation.
Write a C program to calculate profit or loss.
Write a C program to input marks of five subjects Physics, Chemistry, Biology,
Mathematics and Computer. Calculate percentage and grade according to following:
Percentage >= 90% : Grade A
Percentage >= 80% : Grade B
Percentage >= 70% : Grade C
Percentage >= 60% : Grade D
Percentage >= 40% : Grade E
Percentage < 40% : Grade F
Write a C program to input basic salary of an employee and calculate its Gross
salary according to following:
Basic Salary <= 10000 : HRA = 20%, DA = 80%
Basic Salary <= 20000 : HRA = 25%, DA = 90%
Basic Salary > 20000 : HRA = 30%, DA = 95%
Write a C program to input electricity unit charges and calculate total electricity
bill according to the given condition:
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the bill

SWITCH CASE EXERCISE

Write a C program to print day of week name using switch case.


Write a C program print total number of days in a month using switch case.
Write a C program to check whether an alphabet is vowel or consonant using switch
case.
Write a C program to find maximum between two numbers using switch case.
Write a C program to check whether a number is even or odd using switch case.
Write a C program to check whether a number is positive, negative or zero using
switch case.
Write a C program to find roots of a quadratic equation using switch case.
Write a C program to create Simple Calculator using switch case

LOOP AND ITERATION EXERCISES

Write a C program to print all natural numbers from 1 to n. - using while loop
Write a C program to print all natural numbers in reverse (from n to 1). - using
while loop
Write a C program to print all alphabets from a to z. - using while loop
Write a C program to print all even numbers between 1 to 100. - using while loop
Write a C program to print all odd number between 1 to 100.
Write a C program to find sum of all natural numbers between 1 to n.
Write a C program to find sum of all even numbers between 1 to n.
Write a C program to find sum of all odd numbers between 1 to n.
Write a C program to print multiplication table of any number.
Write a C program to count number of digits in a number.
Write a C program to find first and last digit of a number.
Write a C program to find sum of first and last digit of a number.
Write a C program to swap first and last digits of a number.
Write a C program to calculate sum of digits of a number.
Write a C program to calculate product of digits of a number.
Write a C program to enter a number and print its reverse.
Write a C program to check whether a number is palindrome or not.
Write a C program to find frequency of each digit in a given integer.
Write a C program to enter a number and print it in words.
Write a C program to print all ASCII character with their values.
Write a C program to find power of a number using for loop.
Write a C program to find all factors of a number.
Write a C program to calculate factorial of a number.
Write a C program to find HCF (GCD) of two numbers.
Write a C program to find LCM of two numbers.
Write a C program to check whether a number is Prime number or not.
Write a C program to print all Prime numbers between 1 to n.
Write a C program to find sum of all prime numbers between 1 to n.
Write a C program to find all prime factors of a number.
Write a C program to check whether a number is Armstrong number or not.
Write a C program to print all Armstrong numbers between 1 to n.
Write a C program to check whether a number is Perfect number or not.
Write a C program to print all Perfect numbers between 1 to n.
Write a C program to check whether a number is Strong number or not.
Write a C program to print all Strong numbers between 1 to n.
Write a C program to print Fibonacci series up to n terms.

Write a C program to find one's complement of a binary number.


Write a C program to find two's complement of a binary number.
Write a C program to convert Binary to Octal number system.
Write a C program to convert Binary to Decimal number system.
Write a C program to convert Binary to Hexadecimal number system.
Write a C program to convert Octal to Binary number system.
Write a C program to convert Octal to Decimal number system.
Write a C program to convert Octal to Hexadecimal number system.
Write a C program to convert Decimal to Binary number system.
Write a C program to convert Decimal to Octal number system.
Write a C program to convert Decimal to Hexadecimal number system.
Write a C program to convert Hexadecimal to Binary number system.
Write a C program to convert Hexadecimal to Octal number system.
Write a C program to convert Hexadecimal to Decimal number system.
Write a C program to print Pascal triangle upto n rows.
Star pattern programs - Write a C program to print the given star patterns.
Number pattern programs - Write a C program to print the given number patterns.

FUNCTIONS AND RECURSION EXERCISES

Write a C program to find cube of any number using function.


Write a C program to find diameter, circumference and area of circle using
functions.
Write a C program to find maximum and minimum between two numbers using functions.
Write a C program to check whether a number is even or odd using functions.
Write a C program to check whether a number is prime, Armstrong or perfect number
using functions.

Write a C program to find all prime numbers between given interval using functions.
Write a C program to print all strong numbers between given interval using
functions.
Write a C program to print all Armstrong numbers between given interval using
functions.
Write a C program to print all perfect numbers between given interval using
functions.

Write a C program to find power of any number using recursion.


Write a C program to print all natural numbers between 1 to n using recursion.
Write a C program to print all even or odd numbers in given range using recursion.
Write a C program to find sum of all natural numbers between 1 to n using
recursion.
Write a C program to find sum of all even or odd numbers in given range using
recursion.
Write a C program to find reverse of any number using recursion.
Write a C program to check whether a number is palindrome or not using recursion.
Write a C program to find sum of digits of a given number using recursion.
Write a C program to find factorial of any number using recursion.
Write a C program to generate nth Fibonacci term using recursion.
Write a C program to find GCD (HCF) of two numbers using recursion.
Write a C program to find LCM of two numbers using recursion.
Write a C program to display all array elements using recursion.
Write a C program to find sum of elements of array using recursion.
Write a C program to find maximum and minimum elements in array using recursion.

ARRAY EXERCISES

Write a C program to read and print elements of array. - using recursion.


Write a C program to print all negative elements in an array.
Write a C program to find sum of all array elements. - using recursion.
Write a C program to find maximum and minimum element in an array. - using
recursion.
Write a C program to find second largest element in an array.
Write a C program to count total number of even and odd elements in an array.
Write a C program to count total number of negative elements in an array.
Write a C program to copy all elements from an array to another array.
Write a C program to insert an element in an array.
Write a C program to delete an element from an array at specified position.
Write a C program to count frequency of each element in an array.
Write a C program to print all unique elements in the array.
Write a C program to count total number of duplicate elements in an array.
Write a C program to delete all duplicate elements from an array.
Write a C program to merge two array to third array.
Write a C program to find reverse of an array.
Write a C program to put even and odd elements of array in two separate array.
Write a C program to search an element in an array.
Write a C program to sort array elements in ascending or descending order.
Write a C program to sort even and odd elements of array separately.
Write a C program to left rotate an array.
Write a C program to right rotate an array

MATRICES EXERCISES

Write a C program to add two matrices.


Write a C program to subtract two matrices.
Write a C program to perform Scalar matrix multiplication.
Write a C program to multiply two matrices.
Write a C program to check whether two matrices are equal or not.
Write a C program to find sum of main diagonal elements of a matrix.
Write a C program to find sum of minor diagonal elements of a matrix.
Write a C program to find sum of each row and column of a matrix.
Write a C program to interchange diagonals of a matrix.
Write a C program to find upper triangular matrix.
Write a C program to find lower triangular matrix.
Write a C program to find sum of upper triangular matrix.
Write a C program to find sum of lower triangular matrix.
Write a C program to find transpose of a matrix.
Write a C program to find determinant of a matrix.
Write a C program to check Identity matrix.
Write a C program to check Sparse matrix.
Write a C program to check Symmetric matrix.

STRING EXERCISE

Write a C program to find length of a string.


Write a C program to copy one string to another string.
Write a C program to concatenate two strings.
Write a C program to compare two strings.

Write a C program to convert lowercase string to uppercase.


Write a C program to convert uppercase string to lowercase.
Write a C program to toggle case of each character of a string.

Write a C program to find total number of alphabets, digits or special character in


a string.
Write a C program to count total number of vowels and consonants in a string.
Write a C program to count total number of words in a string.
Write a C program to find reverse of a string.
Write a C program to check whether a string is palindrome or not.
Write a C program to reverse order of words in a given string
Write a C program to find first occurrence of a character in a given string.
Write a C program to find last occurrence of a character in a given string.
Write a C program to search all occurrences of a character in given string.
Write a C program to count occurrences of a character in given string.
Write a C program to find highest frequency character in a string.
Write a C program to find lowest frequency character in a string.
Write a C program to count frequency of each character in a string.
Write a C program to remove first occurrence of a character from string.
Write a C program to remove last occurrence of a character from string.
Write a C program to remove all occurrences of a character from string.
Write a C program to remove all repeated characters from a given string.
Write a C program to replace first occurrence of a character with another in a
string.
Write a C program to replace last occurrence of a character with another in a
string.
Write a C program to replace all occurrences of a character with another in a
string.
Write a C program to find first occurrence of a word in a given string.
Write a C program to find last occurrence of a word in a given string.
Write a C program to search all occurrences of a word in given string.
Write a C program to count occurrences of a word in a given string.
Write a C program to remove first occurrence of a word from string.
Write a C program to remove last occurrence of a word in given string.
Write a C program to remove all occurrence of a word in given string.
Write a C program to trim leading white space characters from given string.
Write a C program to trim trailing white space characters from given string.
Write a C program to trim both leading and trailing white space characters from
given string.
Write a C program to remove all extra blank spaces from given string.

POINTERS EXERCISE

Write a C program to create, initialize and use pointers.


Write a C program to add two numbers using pointers.
Write a C program to swap two numbers using pointers.
Write a C program to input and print array elements using pointer.
Write a C program to copy one array to another using pointers.
Write a C program to swap two arrays using pointers.
Write a C program to reverse an array using pointers.
Write a C program to search an element in array using pointers.
Write a C program to access two dimensional array using pointers.
Write a C program to add two matrix using pointers.
Write a C program to multiply two matrix using pointers.
Write a C program to find length of string using pointers.
Write a C program to copy one string to another using pointers.
Write a C program to concatenate two strings using pointers.
Write a C program to compare two strings using pointers.
Write a C program to find reverse of a string using pointers.
Write a C program to sort array using pointers.
Write a C program to return multiple value from function using pointers.

FILES HANDLING EXERCISES

Write a C program to create a file and write contents, save and close the file.
Write a C program to read file contents and display on console.
Write a C program to read numbers from a file and write even, odd and prime numbers
to separate file.
Write a C program to append content to a file.
Write a C program to compare two files.
Write a C program to copy contents from one file to another file.
Write a C program to merge two file to third file.
Write a C program to count characters, words and lines in a text file.
Write a C program to remove a word from text file.
Write a C program to remove specific line from a text file.
Write a C program to remove empty lines from a text file.
Write a C program to find occurrence of a word in a text file.
Write a C program to count occurrences of a word in a text file.
Write a C program to count occurrences of all words in a text file.
Write a C program to find and replace a word in a text file.
Write a C program to replace specific line in a text file.
Write a C program to print source code of same program.
Write a C program to convert uppercase to lowercase character and vice versa in a
text file.
Write a C program to find properties of a file using stat() function.
Write a C program to check if a file or directory exists.
Write a C program to rename a file using rename() function.
Write a C program to list all files and sub-directories recursively.

You might also like