a guest Jan 17th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- Problem 1. Declare Variables
- Declare five variables choosing for each of them the most appropriate of the types byte, short, int, long to represent the following values: 52130, -115, 4825932, 97, -10000.
- Choose a large enough type for each number to ensure it will fit in it. Try to compile the code.
- Problem 2. Float or Double?
- Which of the following values can be assigned to a variable of type float and which to a variable of type double: 34.567839023, 12.345, 8923.1234857, 3456.091?
- Write a program to assign the numbers in variables and print them to ensure no precision is lost.
- Problem 3. Quotes in Strings
- Declare two string variables and assign them with following value: The "use" of quotations causes difficulties.
- Do the above in two different ways - with and without using quoted strings.
- Print the variables to ensure that their value was correctly defined.
- Problem 4. Exchange Variable Values
- Declare two integer variables a and b and assign them with 5 and 10 and after that exchange their values by using some programming logic.
- Print the variable values
- Problem 5. Divide by 7 and 5
- Write a Boolean expression that checks for given integer if it can be divided (without remainder) by 7 and 5 at the same time.
- Problem 6. Sum of 3 Numbers
- Write a program that reads 3 real numbers from the console and prints their sum.
- Problem 7. Numbers from 1 to n
- Write a program that reads an integer number n from the console and prints all the numbers in the interval [1..n], each on a single line.
- Problem 8. The Biggest of 3 Numbers
- Write a program that read 3 numbers and finds the biggest of three numbers.
- Problem 9. Numbers Not Divisible by 3 and 7
- Write a program that enters from the console a positive integer n and prints all the numbers from 1 to n not divisible by 3 or 7, on a single line, separated by a space.
RAW Paste Data