0% found this document useful (0 votes)
15 views5 pages

C Programming Exercises and Solutions

The document outlines various programming tasks in C, including salary calculations, grade determination, power consumption billing, geometric calculations, and data structures. It includes tasks for handling user input, performing mathematical operations, and implementing control structures. Additionally, it covers topics like recursion, string manipulation, and conditional statements.

Uploaded by

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

C Programming Exercises and Solutions

The document outlines various programming tasks in C, including salary calculations, grade determination, power consumption billing, geometric calculations, and data structures. It includes tasks for handling user input, performing mathematical operations, and implementing control structures. Additionally, it covers topics like recursion, string manipulation, and conditional statements.

Uploaded by

sanikaadke206
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. Ramesh’s basic salary is input through the keyboard.

His dearness
allowance is 40% of basic salary, and house rent allowance is 20%
of basic salary. Write a program to calculate his gross salary.
2. Write and Execute the C program to print the grades of students
based on

percentage. Grade: Distinction If per>=75


Grade: A If per>=60 and Per<75
Grade: B If per>=55 and Per<60
Grade: Pass If per>=40 and per<55
Grade: Fail if per<40.
============================================
=======================

1. An Electric power distribution company charges are as follows.


 for 0-200 units -- rs. 0.5/unit
 for 201-400 units-- rs 100+0.65/unit excess of 200units
 for 401-600 units-- rs 230+0.80/unit excess of 400units
 for 601 and above units-- rs 390+1.00/unit excess of
600units

Input customer number and power units consumed. Print amount to


be paid.

2. A bank introduced an intensive policy of giving bonus to all account


holders. The policy is as follows: A bonus of 2% of the balance is
given to everyone. irrespective of their balance and 5% to women if
their balance is more than 5000. Enter the balance, gender, and
calculate the bonus.

============================================
=======================

1. The length & breadth of a rectangle and radius of a circle are input
through the keyboard. Write a program to calculate the area &
perimeter of the rectangle, and the area & circumference of the
circle.
2. write a program to check whether the triangle is isosceles,
equilateral, scalene or Right-angled triangle.

============================================
=======================

1. Two numbers are input through the keyboard into two locations C
and D. Write a program to interchange the contents of C and D.
2. Write C program to calculate addition of two 3X3 matrices.

============================================
=======================

1. Write a program in C for Celsius to Fahrenheit conversion.


2. Write C program to calculate multiplication of two 3X3 matrices.

============================================
=======================
1. Develop program to show the use of explicit typecasting
2. Write C program to Find factorial of a given number using function.

============================================
=======================

1. Develop a program to print the largest of two numbers using


conditional operator.
2. Create a function to find GCD of given number. Call this function in a
program

============================================
========================

1. Identify whether given number is Positive even, Positive odd,


Negative even or Negative odd.
2. Write a C program to determine whether a string is palindrome.

============================================
========================

1. Write a program using conditional operator to check whether a


user can vote or not based on their age.
2. Create a structure called a "employee" having members- empid,
ename, salary. Accept and Display 10 employees ’s information
using structure.

============================================
========================

1. Write a program to find whether the given number is even and


divisible by 5 or not.
2. Create a structure called a library to hold details of the book viz.
accession number, title of the book, author name, price of the book
and flag indicating whether book is issued or not. Fetch some
sample data and display the same.

============================================
========================

1. Write a C program to determine whether a given year is a leap year


or not.
2. Write a program in C to calculate Addition, Subtraction,
Multiplication, Division using pointer.

============================================
========================

1. Write a C Program to print odd numbers from 1 to 100.


2. Find the greatest/smallest number between the given 3 numbers.

============================================
========================
1. Find sum of digits of a given number using do-while loop.
2. Write C program to print array in ascending order.

============================================
========================

1. Write C Program to print following or similar pattern.

1
1 2
1 2 3
1 2 3 4
2. Develop and execute C program to Add Two distances given in
kilometer-meter using structures.

============================================
========================

1. Write a C program to print day of the week by taking number from 1


to 7 using switch statement.
2. Write a C Program to generate Fibonacci series using recursion.

============================================
========================

1. Print student's grade by accepting percent marks using switch


statement.
2. A record contains the name of cricketer, his age, number of test
matches that he has played and the average runs that he has
scored in each test match. Create an array of structure to hold
records of 20 such cricketer and then write a program to read these
records.

============================================
========================

1. Find sum of digits of a given number using do-while loop.


2. Write a program in C to find and print the factorial of a number
using recursive function.

============================================
========================

1. Write C Program to print following or similar pattern.

* * * *
* * *
* *
*
2. Write a program to demonstrate any six string library functions.

============================================
========================
1. Generate multiplication table up to 10 for numbers 1 to 5.
2. Write a C Program to find Prime factors of number using recursion.

============================================
========================

1. Write C program to Calculate Length of given string.


2. Create a structure called a "library" having members- title,
author,price. Accept and Display 10 books information using
structure.

============================================
========================

1. Write a program that accepts marks of 5 subjects calculate the


percentage and display grade of student from percentage. (Grade
Distinction, first class, second class, pass class, fail). (use else-if
ladder)
2. Write a C program that reads the value in the range of 1 -12 and
print the name of that month and next month. Print error for any
other value.

============================================
========================

1. The length & breadth of a rectangle and radius of a circle are input
through the keyboard. Write a program to calculate the area &
perimeter of the rectangle, and the area & circumference of the
circle.
2. Write a C Program to find Prime factors of number using recursion.

============================================
========================

1. A bank introduced an intensive policy of giving bonus to all account


holders. The policy is as follows: A bonus of 2% of the balance is
given to everyone. irrespective of their balance and 5% to women if
their balance is more than 5000. Enter the balance, gender, and
calculate the bonus.
2. Write a C program to print day of the week by taking number from 1
to 7 using switch statement.

============================================
========================

1. Create a structure called a "library" having members- title,


author,price. Accept and Display 10 books information using
structure.
2. A store gives discounts based on membership status and the
amount spent. Members spending over Rs.10000 get a 10%
discount, non-members spending over Rs.15000 get a 5% discount,
and all others get no discount.
============================================
========================

You might also like