Thursday, September 11, 2014

Day 2 - Delivery 3: Using printf() and scanf()

1. Use the printf() statement and do the following:
Print out the value of the integer variable sum
Print out the text string "Welcome", followed by a new line.
Print out the character variable letter
Print out the float variable discount
Print out the float variable dump using two decimal places




2. Use the scanf() and do the following:
To read a decimal value from the keyboard, into the integer variable sum
To read a float variable into the varibale discount_rate
Print the ASCII values of the characters 'A' and 'b'



3. Write a program which takes name, basic , daper ( ie, percentage of D.A), bonper (ie, percentage bonus) and loandet ( loan amount to be debited) for an employee. Calculate the salary using the following relation:
salary = basic + basic * daper /100 +bonper                 
        *  basic/100 - loandet
Data is :
 
name
basic
daper
bonper
loandet
MARK
2500
55
33.33
250.00
Calculate salary and then print the result under the following headings.
(Salary to be printed to the nearest dollar.)
        Name                                    Basic                        Salary


4. Write a program that asks for your first name and last name, and then prints the names in the format last name, first name.


*Chú ý:
- Có 2 cách khai báo chuỗi:
char *x = "hello";
hoặc
char x[10] = "hello";
- ASCII là bộ kí tự và bộ mã kí tự dựa trên bảng chữ cái La Tinh được dùng trong tiếng Anh hiện đại và các ngôn ngữ Tây Âu khác. Có 95 kí tự ASCII in được, được đánh số từ 32 đến 126 (tham khảo thêm tại http://vi.wikipedia.org/wiki/ASCII).

No comments:

Post a Comment