Uploaded by Quote Comets

Basic Practice Problem print and mathmatical (1)

advertisement
Basics C problems
1. Write a C program to print your name, date of birth and mobile number.
Sample Output:
Name : Alexandra Abramov
DOB
: July 14, 1975
Mobile : 99-9999999999
2. Write a C program to print this output
Sample Output:
Hello
nice
to
meet
you
3. Write a C program to print this pattern using printf.
Sample Output:
*
**
***
****
*****
4.Take input of all data types and print it.
Sample input:
Enter integer value : 2
Enter float value : 2.334
Enter double value : 2.434233434
Enter character value : G
SampleOutput:
Integer value : 2
Float value : 2.334
Double value : 2.434233434
Character value : G
5. Write a C program to convert decimal to octal. ( Vice Versa )
SampleInput:
Enter a number: 8
Sample Output:
Octal value is: 10
Hint: Use relevant Format specifiers.
6. Write a C program to convert decimal to hexadecimal. ( Vice Versa )
Sample Input:
Enter a number: 16
Sample Output:
Hexadecimal value is: 10
Hint: Use relevant Format specifiers.
7. Write a C program to convert a character to ASCII value. ( Vice Versa )
Sample Input:
Enter a character: a
Sample Output:
ASCII value is: 97
8. Write a C program to convert a lowercase character to Uppercase character.
( Vice Versa )
Sample Input:
Enter a character: a
Sample Output:
Uppercase character is: A
9. Write a C program to input two numbers and perform all arithmetic
operations to find sum, difference, product, quotient and modulus of two
given numbers.
Sample Input:
First number: 10
Second number: 5
Sample Output:
Sum = 15
Difference = 5
Product = 50
Quotient = 2
Modulus = 0
10. Write a C program to take three integers and print their average.
Sample Input:
Enter three number: 10 20 11
Sample Input:
The average is: 13.667
11. Write a C program to calculate the volume of the sphere.
Sample input:
Enter the radius: 10
Sample Output:
The volume is: 4188.79999
Note: PI = 3.1416. [ Find Area of Circle, Triangle, Rectangle ]
Formula :
12. Write a C Program to convert the inches to feet.
Sample Input:
Enter height is inches: 65
Sample Output:
Your height is 5 feet 5 inches
13. Write a C program to input principle, time and rate (P, T, R) from the user
and find Simple Interest and principal plus interest.
Sample Input:
Enter principle: 1200
Enter time: 2
Enter rate: 5.4
Sample Output:
Simple Interest = 129.600006
Principal + Interest = 1329.6
Hint: Formula to find simple interest:
14. Write a C program that takes a positive float number and outputs its
integer part and real part.
Sample Input:
Enter Number: 3.578
Sample Output:
Integer part: 3
Real part: .578
Hint: To find the real part, you can subtract the integer part from the number.
15. Write a C program that accepts an employee's total worked hours of a
month and the amount he received per hour. Print salary (with two decimal
places) of a particular month.
Sample input:
Input the working hrs: 8
Salary amount/hr: 15000
Sample Output:
Salary = 120000.00
​16. Write a C program to input temperature in Centigrade and convert to
Fahrenheit.
Sample Input:
Enter temperature in Celsius = 100
Sample Output:
Temperature in Fahrenheit = 212.0 F
Hint: Temperature conversion formula from degree Celsius to Fahrenheit is
given by -
17. Write a C program to input temperature in degree Fahrenheit and convert
it to degree Centigrade.
Sample Input:
Temperature in fahrenheit = 205
Sample Output:
Temperature in celsius = 96.11 C
Hint: Formula to convert from degree Fahrenheit to degree Celsius is given
by
18. Write a C program to convert a given integer (in days) to years, months
and days, assuming that all months have 30 days and all years have 365
days.
Sample Input:
Input no. of days: 2535
Sample Output:
Year = 6
Month = 11
Day = 15
Hint: It is similar to the Feet-Inches problem. First find the number of years
and the remaining number of days. Then convert the remaining number of
days into months and days.
19. Write a C program that accepts two item’s weight (floating points' values
) and number of purchases (floating points' values) and calculate the
average value of the items.
Sample Input:
Weight - Item1: 15
No. of item1: 5
Weight - Item2: 25
No. of item2: 4
Sample Output:
Average Value = 19.444444
Hint: Find the total weight and total number of objects and then use it to find
the average.
20. Write a C program to find all roots of a quadratic equation (ax^2 + bx + c = 0).
Example - 1 :
Sample Input:
Input a: 8
Input b: -4
Input c: -2
Sample Output:
There are two roots.
Root 1: 0.80
Root 2: -0.30
Example - 2 :
Sample Input:
Input a: 1
Input b: 4
Input c: 5
Sample Output:
Complex root.
Hint :
Download