#1 DataTypes&Conditions
#1 DataTypes&Conditions
Input
Only one line containing a string S.
Output
Print “Hello, ” without quotes, then print name.
Example
standard input standard output
programmer Hello, programmer
Page 1 of 1
Basic Data Types
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
The following lines show some C++ data types, their format specifiers and their most common bit
widths:
Reading
Printing
Page 1 of 2
For example, to print a character followed by a double:
Input
Only one line containing the following space-separated values: int, long long, char,
float and double respectively.
Output
Print each element on a new line in the same order it was received as input.
Example
standard input standard output
3 12345678912345 a 334.23 14049.30493 3
12345678912345
a
334.23
14049.3
Page 2 of 2
,
Simple Calculator
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Given two numbers X and Y . Print the summation and multiplication and subtraction of these 2
numbers.
Input
Only one line containing two separated numbers X, Y (1 ≤ X, Y ≤ 105 ).
Output
Print 3 lines that contain the following in the same order:
Example
standard input standard output
5 10 5 + 10 = 15
5 * 10 = 50
5 - 10 = -5
Note
Be careful with spaces.
Page 1 of 1
,
Difference
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Given four numbers A, B, C and D. Print the result of the following equation :
X = (A ∗ B) − (C ∗ D).
Input
Only one line containing 4 separated numbers A, B, C and D (−105 ≤ A, B, C, D ≤ 105 ).
Output
Print “Difference = 00 without quotes followed by the equation result.
Examples
standard input standard output
1 2 3 4 Difference = -10
2 3 4 5 Difference = -14
4 5 2 3 Difference = 14
Page 1 of 1
,
Area of a Circle
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Given a number R calculate the area of a circle using the following formula:
Area = π * R2.
Note: consider π = 3.141592653.
Input
Only one line containing the number R (1 ≤ R ≤ 100).
Output
Print the calculated area, with 9 digits after the decimal point.
Example
standard input standard output
2.00 12.566370612
Note
* Use the data type double for this problem.
*** you can use function setprecision that are in #include<iomanip> library for Example :
Page 1 of 1
,
Digits Summation
Input file: standard input
Output file: standard output
Time limit: 0.25 seconds
Memory limit: 64 megabytes
Given two numbers N and M . Print the summation of their last digits.
Input
Only one line containing two numbers N, M (0 ≤ N, M ≤ 1018 ).
Output
Print the answer of the problem.
Example
standard input standard output
13 12 5
Note
First Example :
last digit in the first number is 3 and last digit in the second number is 2.
So the answer is: (3 + 2 = 5)
Page 1 of 1
,
Summation from 1 to N
Input file: standard input
Output file: standard output
Time limit: 0.25 seconds
Memory limit: 256 megabytes
Given a number N . Print the summation of the numbers that is between 1 and N (inclusive).
N
X
. i
i=1
Input
Only one line containing a number N (1 ≤ N ≤ 109 )
Output
Print the summation of the numbers that are between 1 and N (inclusive).
Examples
standard input standard output
3 6
10 55
Note
First Example :
the numbers between 1 and 3 are 1,2,3 .
So the answer is: (1 + 2 + 3 = 6)
Second Example :
the numbers between 1 and 10 are 1,2,3,4,5,6,7,8,9,10.
So the answer is: (1 + 2 + 3 + 4 + 5 + 6 +7 +8 + 9 + 10 = 55)
Page 1 of 1
Two numbers
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
• Floor: Is a mathematical function that takes a real number X and its output is the greatest integer
less than or equal to X.
• Ceil: Is a mathematical function that takes a real number X and its output is the smallest integer
larger than or equal to X.
• Round: Is a mathematical function that takes a real number X and its output is the closest integer
to that number X.
Input
Only one line containing two numbers A and B (1 ≤ A, B ≤ 103 )
Page 1 of 2
Output
Print 3 lines that contain the following in the same order:
Examples
standard input standard output
10 3 floor 10 / 3 = 3
ceil 10 / 3 = 4
round 10 / 3 = 3
10 4 floor 10 / 4 = 2
ceil 10 / 4 = 3
round 10 / 4 = 3
10 6 floor 10 / 6 = 1
ceil 10 / 6 = 2
round 10 / 6 = 2
Note
Links:
Page 2 of 2
,
Given two numbers A and B. Print “Yes” if A is greater than or equal to B. Otherwise print “No”.
Input
Only one line containing two numbers A and B (0 ≤ A, B ≤ 100).
Output
Print “Yes” or “No” according to the statement.
Examples
standard input standard output
10 9 Yes
5 5 Yes
5 7 No
Page 1 of 1
,
Multiples
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Given two numbers A and B. Print “Multiples” if A is multiple of B or vice versa. Otherwise print “No
Multiples”.
Input
Only one line containing two numbers A, B (1 ≤ A, B ≤ 106 )
Output
Print the “Multiples” or “No Multiples” corresponding to the read numbers.
Examples
standard input standard output
9 3 Multiples
6 24 Multiples
12 5 No Multiples
Note
***A is said to be Multiple of B if B is divisible by A.
First Example :
9 is divisible by 3 , So the answer is: Multiples.
Second Example :
6 is not divisible by 24 but
24 is divisible by 6 , So the answer is: Multiples.
Third Example :
12 is not divisible by 5 and 5 is not divisible by 12.
So the answer is: No Multiples.
Page 1 of 1
,
Given 3 numbers A, B and C, Print the minimum and the maximum numbers.
Input
Only one line containing 3 numbers A, B and C (−105 ≤ A, B, C ≤ 105 )
Output
Print the minimum number followed by a single space then print the maximum number.
Examples
standard input standard output
1 2 3 1 3
-1 -2 -3 -3 -1
10 20 -5 -5 20
Page 1 of 1
,
The Brothers
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Input
First line will contain two Strings F1 , S1 which donates the first and second name of the 1s t person.
Second line will contain two Strings F2 , S2 which donates the first and second name of the 2n d person.
Output
Print “ARE Brothers” if they are brothers otherwise print “NOT”.
Examples
standard input standard output
bassam ramadan ARE Brothers
ahmed ramadan
ali salah ARE Brothers
ayman salah
ali kamel NOT
ali salah
Page 1 of 1
,
Input
Only one line containing a character X which will be a capital or small letter or digit.
Output
Print a single line contains “IS DIGIT” if X is digit otherwise, print “ALPHA” in the first line followed
by a new line that contains “IS CAPITAL” if X is a capital letter and “IS SMALL” if X is a small
letter.
Examples
standard input standard output
A ALPHA
IS CAPITAL
9 IS DIGIT
a ALPHA
IS SMALL
Note
** recommended to read this to know more about ASCII Code https://www.javatpoint.com/ascii.
Page 1 of 1
,
Char
Input file: standard input
Output file: standard output
Time limit: 0.25 seconds
Memory limit: 64 megabytes
Given a letter X. If the letter is lowercase print the letter after converting it from lowercase letter to
uppercase letter. Otherwise print the letter after converting it from uppercase letter to lowercase
letter
Note : difference between ’a’ and ’A’ in ASCII is 32 .
Input
Only one line containing a character X which will be a capital or small letter.
Output
Print the answer to this problem.
Examples
standard input standard output
a A
A a
Page 1 of 1
Calculator
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Given a mathematical expression. The expression will be one of the following expressions: A + B, A − B,
A ∗ B and A/B.
Print the result of the mathematical expression.
Input
Only one line contains A, S and B (1 ≤ A, B ≤ 104 ), S is either (+, −, ∗, /).
Output
Print the result of the mathematical expression.
Examples
standard input standard output
7+54 61
17*10 170
Note
For the dividing operation you should print the division without any fractions.
Page 1 of 1
,
First digit !
Input file: standard input
Output file: standard output
Time limit: 0.25 seconds
Memory limit: 64 megabytes
Given a number X. Print ”EVEN” if the first digit of X is even number. Otherwise print ”ODD”.
For example: In 4569 the first digit is 4, the second digit is 5, the third digit is 6 and the fourth digit
is 9.
Input
Only one line containing a number X (999 < X ≤ 9999)
Output
If the first digit is even print 00 EV EN 00 otherwise print 00 ODD00 .
Examples
standard input standard output
4569 EVEN
3569 ODD
Note
Second Example :
In 3569 the first digit is 3 and its ODD.
Page 1 of 1
,
Coordinates of a Point
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Given two numbers X, Y which donate coordinates of a point in 2D plan. Determine in which quarter
does it belong.
Note:
• Print Q1, Q2, Q3, Q4 according to the quarter in which the point belongs to.
Input
Only one line containing two numbers X, Y (−1000 ≤ X, Y ≤ 1000).
Output
Print the answer to problem above.
Examples
standard input standard output
4.5 -2.2 Q4
0.1 0.1 Q1
Page 1 of 1
,
Age in Days
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Given a Number N corresponding to a person’s age (in days). Print his age in years, months and days,
followed by its respective message “years”, “months”, “days”.
Note: consider the whole year has 365 days and 30 days per month.
Input
Only one line containing a number N (0 ≤ N ≤ 106 ).
Output
Print the output, like the following examples.
Examples
standard input standard output
400 1 years
1 months
5 days
800 2 years
2 months
10 days
30 0 years
1 months
0 days
Page 1 of 1
,
Interval
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Given a number X. Determine in which of the following intervals the number X belongs to:
[0,25], (25,50], (50,75], (75,100]
Note:
• if X belongs to any of the above intervals print “Interval ” followed by the interval.
• if X does not belong to any of the above intervals print “Out of Intervals”.
For example:
[0,25] indicates numbers between 0 and 25.0000, including both.
(25,50] indicates numbers greater than 25: (25.00001) up to 50.0000000.
Input
Only one line containing a number X (−1000 ≤ X ≤ 1000).
Output
Print the answer to the problem above.
Examples
standard input standard output
25.1 Interval (25,50]
25.0 Interval [0,25]
100.0 Interval (75,100]
-25.2 Out of Intervals
Page 1 of 1
,
Sort Numbers
Input file: standard input
Output file: standard output
Time limit: 0.25 seconds
Memory limit: 256 megabytes
Given three numbers A, B, C. Print these numbers in ascending order followed by a blank line and then
the values in the sequence as they were read.
Input
Only one line containing three numbers A, B, C (−106 ≤ A, B, C ≤ 106 )
Output
Print the values in ascending order followed by a blank line and then the values in the sequence as they
were read.
Examples
standard input standard output
3 -2 1 -2
1
3
3
-2
1
-2 10 0 -2
0
10
-2
10
0
Page 1 of 1
,
Float or int
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
• If N is float number then print “float” followed by the integer part followed by decimal part
separated by space.
• If N is integer number then print “int” followed by the integer part separated by space.
Input
Only one line containing a number N (1 ≤ N ≤ 103 )
Output
Print the answer required above.
Examples
standard input standard output
234.000 int 234
534.958 float 534 0.958
Page 1 of 1
,
Comparison
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Given a comparison symbol S between two numbers A and B. Determine whether it is Right or W rong.
The comparison is as follows: A < B, A > B, A = B.
Where A, B are two integer numbers and S refers to the sign between them.
Input
Only one line containing A, S and B respectively (-100 ≤ A, B ≤ 100), S can be (‘<’, ‘>’,‘=’) without
the quotes.
Output
Print “Right” if the comparison is true, “Wrong” otherwise.
Examples
standard input standard output
5 > 4 Right
9 < 1 Wrong
4 = 4 Right
Page 1 of 1
,
Mathematical Expression
Input file: standard input
Output file: standard output
Time limit: 0.25 seconds
Memory limit: 256 megabytes
Given a mathematical expression. The expression will be one of the following expressions:
A + B = C, A − B = C and A ∗ B = C
where A, B, C are three numbers, S is the sign between A and B, and Q the ‘=’ sign
Print “Yes” If the expression is Right , Otherwise print the right answer of the expression.
Input
Only one line containing the expression: A, S, B, Q, C respectively (0 ≤ A, B ≤ 100, −105 ≤ C ≤ 105 )
and S can be (‘+’, ‘-’, ‘*’) without the quotation.
Output
Output either “Yes"(without the quotation) or the right answer depending on the statement.
Examples
standard input standard output
5 + 10 = 15 Yes
3 - 1 = 2 Yes
2 * 10 = 19 20
Page 1 of 1
Two intervals
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Input
Only one line contains two intervals [l1 , r1 ], [l2 , r2 ] where (1 ≤ l1 , l2 , r1 , r2 ≤ 109 ), (l1 ≤ r1 , l2 ≤ r2 ).
It’s guaranteed that l1 ≤ r1 and l2 ≤ r2 .
Output
If there is an intersection between these 2 intervals print its boundaries , otherwise print -1.
Examples
standard input standard output
1 15 5 27 5 15
2 5 6 12 -1
Note
First Example :
Second Example :
Page 1 of 2
Page 2 of 2
,
Given 4 numbers A, B, C and D. Print the last 2 digits from their Multiplication.
Input
Only one line containing four numbers A, B, C and D (2 ≤ A, B, C, D ≤ 109 ).
Output
Print the last 2 digits from their Multiplication.
Examples
standard input standard output
5 7 2 4 80
3 9 9 9 87
Note
First Example :
the Multiplication of 4 numbers is 5 * 7 * 2 * 4 = 280 so the answer will be the last 2 digits which are
80.
Second Example :
the Multiplication of 4 numbers is 3 * 9 * 9 * 9 = 2187 so the answer will be the last 2 digits which
are 87.
Page 1 of 1
Hard Compare
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Input
Only one line containing 4 numbers A, B, C and D (1 ≤ A, C ≤ 107 ) , (1 ≤ B, D ≤ 1012 )
Output
Print "YES"or "NO"according to the problem above.
Examples
standard input standard output
3 2 5 4 NO
5 2 4 2 YES
5 2 5 2 NO
Note
First Example :
32 = 9 and 54 = 625 then 9 < 625 so the answer is NO.
Second Example :
52 = 25 and 42 = 16 then 25 > 16 so the answer is YES.
Third Example :
52 = 25 and 52 = 25 then 25 = 25 so the answer is NO.
Page 1 of 1