You are on page 1of 2

Fondamenti di Programmazione

Laboratorio 01
01 - Write a complete program that prompts the user to enter three integers and calculates the product. 02 - Write a program that asks the user to enter two numbers obtains the two numbers from the user and prints the sum, product, difference, quotient and remainder of the two numbers. 03 - Write a program that prints the numbers 1 to 4 on the same line. Write the program using the following methods. a) Using one printf statement with no conversion specifiers b) Using one printf statement with four conversion specifiers c) Using four printf statements 04 - Write a program that asks the user to enter two integers, obtains the numbers from the user, then prints the larger number followed by the words “is larger.” If the numbers are equal, print the message “These numbers are equal.” Use only the single-selection form of the if. 05 - Write a program that inputs three different integers from the keyboard, then prints the sum, the average, the product, the smallest and the largest of these numbers. Use only the single-selection form of the if statement. 06 - Write a program that reads in the radius of a circle and prints the circle’s diameter, circumference and area. Use the constant value 3.14159 for π. Perform each of these calculations inside the printf statement(s) and use the conversion specifier %f. [Note: we have discussed only integer constants and variables. In the next lecture we will discuss floating-point numbers, i.e., values that can have decimal points.] 07 - Write a program that reads in five integers and then determines and prints the largest and the smallest integers in the group. Use only the programming techniques you have learned until now. 08 - Write a program that reads an integer and determines and prints whether it is odd or even. [Hint: Use the remainder operator. An even number is a multiple of two. Any multiple of two leaves a remainder of zero when divided by 2]

As a minimum. The set of characters a computer uses together with the corresponding integer representations for those characters is called that computer’s character set. You can print the integer equivalent of uppercase A. lowercase letters. you learned about integers and the type int. determine the integer equivalents of the following: A B C a b c 0 1 2 $ * + / and the blank character. lowercase letters and a considerable variety of special symbols. [Hint: Use the remainder operator. by executing the statement printf( "%d".Write a program that reads in two integers and determines and prints if the first is a multiple of the second. Write a C program that prints the integer equivalents of some uppercase letters. C uses small integers internally to represent each different character. 'A' ).] 10 – During the lecture. C can also represent uppercase letters.09 . digits and special symbols. for example. .