Thursday, September 18, 2014
Tuesday, September 16, 2014
Exercice 8-More conditial (day 3)
1. Declare two variables x and y. Assign values to these variables. Number x should be printed only if it is less than 2000 or greater than 3000, and number y should be printed only if it is between 100 and 500.
2. Write a program to show your computer’s capabilities. The user types in a letter of the alphabet and your program should display the corresponding language or package available. Some sample input ans output is given below :
Input Output
A or a Ada
B or b Basic
C or c COBOL
D or d dBASE III
f or F Fortran
p or P Pascal
v or V Visual C++
Using the ‘switch’ statement to choose and display the appropriate message. Use the default label to display a message if the input does not match any of the above letters.
Sunday, September 14, 2014
Exercise 7: More if...(day 3)
1. Write a program that accepts two numbers a and b and checks whether or not a is divisible by b.
2. Write a program to accept 2 numbers and tell whether the product of the two numbers is equal to or greater than 1000.
3. Write a program to accept 2 numbers. Calculate the difference between the two values. If the difference is equal to any of the values entered, then display the following message : Difference is equal to value <number of value entered> If the difference is not equal to any of the values entered, display the following message: Difference is not equal to any of the values entered
Exercise with ball...
Đề bài đơn giản là quả bóng sẽ bị rơi xuống,chúng ta cần cho nó k bị rơi xuống quá màn hình nữa.
Ở bài này,chúng ta sử dụng câu lệnh "if",đặt điều kiện cho sự di chuyển của quả bóng,làm nó k rơi xuống nữa.
Dùng "if" với điều kiện khi ball vượt quá tọa độ 370,nhận đc kết quả tốc độ đổi từ 2 xuống -2(tức là ball đi ngược lên trên)
Tương tự,đặt thêm 1 điều kiện để ball rớt xuống khi qua toạn độ y=30,tránh để ball bay quá màn hình.
Friday, September 12, 2014
Exercise get()/puts()...
1. Write a program to accept and add three numbers.
2. For the following values, write a program to evaluate the expression:
Using printf() and scanf()...
1. Use the printf( ) statement and do the following:
a) Print out the value of the integer variable sum
b) Print out the text string "Welcome", followed by a new line.
c) Print out the character variable letter
d) Print out the float variable discount
e) Print out the float variable dump using two decimal places
2. Use the scanf( ) statement and do the following:
a) To read a decimal value from the keyboard, into the integer variable sum
c)Print the wth Values of the characters ‘A’ and ‘b’.
Subscribe to:
Posts (Atom)