Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

COMPUTER PROGRAMMING 1

CAT

1. Write a program to print the corresponding Celsius to Fahrenheit table.


2. Discuss features of an algorithm
3. Discuss the benefits provided by High-level programming language
4. Write a program for printing prime numbers between 1 and 100
5. Describe the various types of translators used in programming
6. Write a C program that allows the user to input his/her name then the program will show
a welcome message. The example output of the program is shown below:

What is your name? John Egg


Welcome John Egg!
7. Write a C program that allows the user to input money in USD. Then the program will
convert the money to KH currency(riel) and display the result. The exchange rate is
1USD=4100 Riel. The example output of the program is shown below:

Enter money in USD:1000


The money in Riel is:4100000
8. Write a C program to calculate a series of fractions as shown below:

Sn=1/n+1/(n-1)+1/(n-2)+...+1

9. Write a C program that use a recursive function to sum a series of values raised by their
powers as shown below. In a recursive problem, it is important to define the base case
and the general case. The base case is where the recursive function call stops and general
case will be processed when the base case is not met.
This is the C example code to calculate a series of values raised by their powers as shown
below:

Sn=11+22+33+44+...+nn

10. Write a C program that count the number of characters, words, and lines in a file. The use
will be asked to input the file name from keyword. Then the program will output the
number of characters, words, and lines in the file.
11. Write a C program that print a calendar of a specific year. The program asks the user to
input the year for which the calendar would be printed.
12. Write a C program that allows the user to input an integer number. Then the program will
display the number of digits and individual digits of the input number. The example
output of the program is shown below:
Enter a number:1234
The number of digits:4
The digits of the number:1   2   3   4
13. Write a C program that is about calculating value raised by its power. The program
starts by asking the user to input the base value and the its power. Then the program will
print the value raised by its power.

Sample output:

Please enter base value and its power separated by space: 12 2


144.00000
14.Write a C program to prompt the user to input 3 integer values and print these
values in forward and reversed order, as shown below.

 
Please enter your 3 numbers: 12 45 78
 
Your numbers forward:
12
45
78
 
Your numbers reversed:
78
45
12

15.Write C code that will display the calculator menu.

The program will prompt the user to choose the operation choice (from 1 to 5). Then it asks the
user to input two integer vales for the calculation. See the sample below.
  MENU
          1. Add
          2. Subtract
          3. Multiply
          4. Divide
          5. Modulus
Enter your choice: 1
Enter your two numbers: 12 15
Result: 27
 
Continue? y
 
The program also asks the user to decide whether he/she wants to continue the operation. If
he/she input ‘y’, the program will prompt the user to choose the operation gain. Instead, the
program will terminate

You might also like