0% found this document useful (0 votes)
13 views5 pages

Numbers From 1 To 100 - Problem Description

sdfesdf

Uploaded by

Marko Jovanovic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Numbers From 1 To 100 - Problem Description

sdfesdf

Uploaded by

Marko Jovanovic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Lab: For-Loop

Problems for lab exercise for the course "Programming Basics" course @ SoftUni Global
Submit your solutions to the SoftUni Judge system: https://judge.softuni.org/Contests/4583

1. Numbers from 1 to 100


Write a program that prints the numbers from 1 to 100, each on a new line.

Sample Input and Output


Input Output
1
2
3
(no input) …
98
99
100

Hints and Guidelines


Write the solution to the problem by using the code from the picture below:

Testing in the Judge System


Test your solution in the online Judge system https://judge.softuni.org/Contests/Compete/Index/4583#0

2. Numbers 1...N with Step 3


Write a program that reads a number n entered by the user and prints the numbers from 1 to n with step 3.

Sample Input and Output


Input Output Input Output Input Output
10 1 7 1 15 1
4 4 4
7 7 7
10 10
13

Hints and Guidelines


1. Read the input data from the console - an integer n:
2. Make a for-loop from 1 to n (inclusive) and set the step to 3. This means that at each iteration of the loop,
the variable i will increase its value by 3 instead of 1. Print the variable at each iteration:

© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.

Follow us: Page 1 of 5


Testing in the Judge System
Test your solution in the online Judge system https://judge.softuni.org/Contests/Compete/Index/4583#1

3. Even Powers of 2
Write a program that receives a number n and prints the even powers of 2 ≤ 2n: 20, 22, 24, 26, …, 2n.

Sample Input and Output


Input Output Input Output Input Output Input Output Input Output
3 1 4 1 5 1 6 1 7 1
4 4 4 4 4
16 16 16 16
64 64

Testing in the Judge System


Test your solution in the online Judge system https://judge.softuni.org/Contests/Compete/Index/4583#2

4. Numbers N…1
Write a program that reads a positive integer n entered by the user and prints the numbers from n to 1 in reverse
order. The entered number n will always be greater than 1.

Sample Input and Output


Input Output Input Output Input Output
2 2 3 3 5 5
1 2 4
1 3
2
1

Hints and Guidelines


1. Read an integer from the console - the count of numbers to be entered.
2. Make a for loop from n to 0, decrementing the variable i by 1 at each iteration and printing it.

Testing in the Judge System


Test your solution in the online Judge system https://judge.softuni.org/Contests/Compete/Index/4583#3

5. Character Sequence
Write a program that receives text (string) and prints each character of the string on a separate line.

Sample Input and Output


Input Output Input Output
softun s ice cream i

© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.

Follow us: Page 2 of 5


i o c
f e
t
u c
n r
i e
a
m

Hints and Guidelines


To iterate the for loop through the input word in place of the range() function, use directly the variable where
you previously stored the input from the console:

Testing in the Judge System


Test your solution in the online Judge system https://judge.softuni.org/Contests/Compete/Index/4583#4

6. Vowels Sum
Write a program that reads text (string) entered by the user and calculates and prints the sum of the vowel values
according to the table below:

Letter a e i o u
Value 1 2 3 4 5

Sample Input and Output


Input Output Comments
hello 6 e+o = 2+4 = 6
hi 3 i = 3
bambo 9 a+o+o = 1+4+4 =
o 9
beer 4 e+e= 2+2 = 4

Testing in the Judge System


Test your solution in the online Judge system https://judge.softuni.org/Contests/Compete/Index/4583#5

7. Sum Numbers
Write a program that reads n number of integers entered by the user and sums them.
 From the first line of the input, the count of numbers n is entered.
 From the next n lines, one integer is entered at a time.
The program has to read the numbers, sum them and print their sum.

© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.

Follow us: Page 3 of 5


Sample Input and Output
Input Output Input Output Input Output Input Output Input Output
2 30 3 -60 4 43 1 999 0 0
10 -10 45 999
20 -20 -20
-30 7
11

Testing in the Judge System


Test your solution in the online Judge system https://judge.softuni.org/Contests/Compete/Index/4583#6

8. Number sequence
Write a program that reads n number of integers. Print the largest and the smallest number among the entered
ones.

Sample Input and Output


Input Output Input Output

5 Max number: 6 Max number:


10 304 250 1000
20 Min number: 0 5 Min number: 0
304 2
0 0
50 100
100
0

Testing in the Judge System


Test your solution in the online Judge system https://judge.softuni.org/Contests/Compete/Index/4583#7

9. Left and Right Sum


Write a program that reads 2 * n number of integers given by the user and checks if the sum of the first n numbers
(left sum) is equal to the sum of the second n numbers (right sum). If equal, prints "Yes, sum = " + sum;
otherwise prints "No, diff = " + diff. The difference is calculated as a positive number (in absolute value).

Sample Input and Output


Input Output Comments Input Output Comments
2 Yes, sum = 10+90 = 60+40 = 2 No, diff = 90+9 ≠ 50+50
10 100 100 90 1 Difference = |
90 9 99-100| = 1
60 50
40 50

© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.

Follow us: Page 4 of 5


Testing in the Judge System
Test your solution in the online Judge system https://judge.softuni.org/Contests/Compete/Index/4583#8

10. Odd Even Sum


Write a program that reads n number of integers given by the user and checks whether the sum of the numbers in
even positions is equal to the sum of the numbers in odd positions.
 If the sums are equal print two lines: "Yes" and on a new line "Sum = " + sum;
 If the sums are not equal print two lines: "No" and on a new line "Diff = " + the difference;
The difference is calculated by absolute value.

Sample Input and Output


Input Output Comments Input Output Comments Input Output Comments
4 Yes 10+60 = 4 No 3+1 ≠ 5-2 3 No 5+1 ≠ 8
10 Sum = 50+20 = 3 Diff = Diff = 5 Diff = Diff =
50 70 70 5 1 |4-3| = 1 8 2 |6-8| = 2
60 1 1
20 -2

Testing in the Judge System


Test your solution in the online Judge system https://judge.softuni.org/Contests/Compete/Index/4583#9

© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.

Follow us: Page 5 of 5

You might also like