C Programming Practice

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

C PROGRAMMING PRACTICE

1. Write a program that converts the given temperature in Fahrenheit to Celsius using
the following conversion formula: C= (F-32)/1.8
2. Write a program that requests a number from the user and then convert a given
number of days into months and days.
3. Write a program to solution of the quadratic equation. ax2 + bx + c= 0
4. Given the radius of a circle, write a program to compute and display its area.
5. Write a program that requests the user to enter a character and displays a message on
the screen telling the user whether the character is an alphabet or digit, or any other
special character.
6. Write a program that reads a character from keyboard and then prints it in reverse
case that is if the input is upper case, the output will be lower case and vice versa.
7. Write a program that reads four values a, b, c and d from the terminal and evaluates
the ratio of [a+b] to [c-d] and prints the result, if c-d is not equal to zero.
8. Write a program to determine whether a given number is ‘odd’ or ‘even’ and print the
message: Number is Even or Number is Odd.
9. Write a program that will print your mailing address in the following form:
First line : Name
Second line : Roll No.
Third line : University

10. Write a program to read the price of an item in decimal form (like 15.95 tk) and print
the output in paisa (like 1595 paisa).
11. Write a program to calculate the average of a set of N numbers.
12. Write a program that prints the odd numbers from 5 to 35.
13. Write a program that prints the even numbers from 15 to 55.
14. Write a program that selects and prints the largest of the three numbers.
15. Write a program that selects and prints the smallest of the three numbers.
16. Write a program that prints those numbers that are divisible by 5 and not divisible by
8 from the 15 to 75. Also count total number and sum of those numbers.
17. Write a program that computes the sum of the numbers between 1 to 10.
18. Write a program that computes the sum of the square numbers between 1 to 10.
19. Write a program to find the number of and sum of all integers greater than 100 and
less than 200 that are divisible by both 2 and 5.
20. Write a program that takes a number as input and display the sentence “I am a student
of EEE/ECE” that many times.
21. A class of n students take an annual examination in m subjects. Write a program that read the marks
obtained by each student in various subjects and to compute and print the total marks obtained by
each of them.
22. Write a program that prints your name ten times using while loop.
23. Write a program that read a line of text and prints that line.
24. Program to Accept a String and display in Reverse.
25. Program to Accept 2 strings and display the largest string.
26. Accept 2 strings and create third string which will be concatenation of 2strings
ex : string3 = string1 + string2.
27. Program to Accept a String and display vowels.
28. Program to Accept a String and display no of vowels.
29. Program to Accept a String and display no of each Vowel.
30. Program to Accept a String and a character and find out whether this characteris present in the string.
31. Accept 2 strings and check whether all Characters from 1st string are present in 2nd String.
32. Accept String from user and copy it to another string.
33. Accept Multiple strings from user and display.
34. Write a program using for loop to print the following output.

CProgramming
………
…….
CPro
CPr
CP
C
35. Write a program using for loop to print the following output.
C
CP
CPr
………..
CProgramming
36. Write a program that counts the number of boys whose weight is less than 50 kg and
height is greater than 170cm among 10 boys.
37. Write a program to print the following output using for loops.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
38. Write a program for grading system using break statement.
39. An electric power distribution company charges its domestic consumers as follows:

Consumption Units Rate of Charge


0-200 Rs. 0.50 per unit
201-400 Rs. 100 plus Rs. 0.65 per unit excess of 200
401-600 Rs. 230 plus Rs. 0.80 per unit excess of 400
601 and above Rs. 390 plus Rs. 1.00 per unit excess of 600
Write a program that reads the customer number and power consumed and prints the
amount to be paid by the customer.
40. Write a program that compute the factorial for any given n.
41. Implement a C Program which takes a character from the key board and determines it
is vowel or consonant.

42. Write a program to calculate the area of a circle using function that has no arguments
but return a value.
43. Suppose s1, s2, s3 are three string variables. Write a program to read two string
constants into s1 and s2 and compare whether they are equal or not. If they are not,
join them together. Then copy the contents of s1 to the variable s3. At the end, the
program should print the contents of all the three variables and their lengths.
44. Write a program to copy one string into another and count the number of characters
copied.
45. Define a structure called student that will describe the following information:
student name
student id
student gpa
Using student, declare an array student with 50 elements and write a program to read
the information about all the 50 students and print the respective student name,
student id and student gpa.
46. Define a structure data type called time_struct containing three member’s integer
hour, integer minute and integer second. Develop a program that would assign values
to the individual members and display the time in the following form:
10: 20 : 30
47. Admission to a professional course is subject to the following conditions:
a) Marks in Mathematics >=60
b) Marks in Physics >=50
c) Marks in Chemistry >=40
d) Total in all three subjects >=200
Or
Total in Mathematics and Physics >=150
Given the marks in the three subjects, Write a program to process the applications to
list the eligible candidates
48. Write a program to find the number of and sum of all integers greater than 10 and
less than 100 that are divisible by 5.
49. Write a program to compute the sum of the digits of a given integer number.
50. Write a program using pointers to compute the sum of all elements stored in an array.
51. Write a program that generates Fibonacci Series.
52. Write a program that determines whether a given number is prime or not prime.

You might also like