0% found this document useful (0 votes)
5 views2 pages

Loop (Single)

The document outlines a series of programming exercises focused on loops in computer programming. Each exercise requires writing a program to perform specific tasks such as computing sums, averages, ranges, and checking for properties of numbers like perfect, Armstrong, or prime. The exercises are designed to enhance programming skills and understanding of loops and basic mathematical operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Loop (Single)

The document outlines a series of programming exercises focused on loops in computer programming. Each exercise requires writing a program to perform specific tasks such as computing sums, averages, ranges, and checking for properties of numbers like perfect, Armstrong, or prime. The exercises are designed to enhance programming skills and understanding of loops and basic mathematical operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Sinai University

Faculty of Information Technology


Computer Programming
Loops (Single)
1) Write a program to read n integers and compute the sum.
2) Write a program to read some even integers and compute the average.
3) Write a program to read n integers and compute the range. 𝑅𝑎𝑛𝑔𝑒 = 𝑚𝑎𝑥 − 𝑚𝑖𝑛
4) Write a program to read some integers until the user entered 777 and count the number of
entered numbers
5) Write a program to read two integers ( x and y ) and print all numbers between those numbers
6) A number is called perfect if it is equal to the sum of its factors (excluding itself ‫)باستثنائه هو‬.
For example, 6 is perfect because 6=1+2+3. Write a program to read a positive integer and
check whether it is perfect or not.
7) Write a program to read an integer and compute the sum of the squares of its digits.
8) Write a program to read an integer and revers it.
9) An Armstrong number is a special kind of number in math. It's a number that equals the sum
of its digits, each raised to a power n where n is the number of digits. For example, if you have
a number like 153, it's an Armstrong number because 1^3 + 5^3 + 3^3 equals 153. 1634 is an
Armstrong number because 1^4+6^4+3^4+4^4=1634. Write a program to read an integer and
check whether it is Armstrong or not.
10) Write a program to perform a simple calculator. The program will continue to read two
numbers and an operation (+, -, *, /) and perform that operation while the user wants to
continue.
11) For a positive float x (less than 1), write a program to compute the sum of n terms of the
following
𝑥2 𝑥3 𝑥4
𝑥 + + + ……
2 3 4
12) For a float x, write a program to compute the sum of n terms of the following

𝑥 4 𝑥 8 𝑥16
+ + …
2 5 8
13) For a float x, write a program to compute the sum of n terms of the following

𝑥3 𝑥5 𝑥7
− + − ⋯…
3 5 7
14) Write a program to compute the following
1 2 3 4 30
+ + + + ⋯..
30 29 28 27 1
15) Write a program to compute the following
1 2 3 4 99
+ + + + ⋯..
2 3 4 5 100
16) Write a program to compute the sum of n terms of the following series
9 + 99 + 999 + 9999 + 99999 +…
17) Write a program to compute the sum of n terms of the following series
3 + 7 + 33 + 77 + 333 + 777 + 3333 + 7777 +……
18) Write a program to read an integer and check whether it is prime or not.
19) Write a program that reads integers with different signs, adds them, and stops when two
integers with the same sign are entered
20) Write a program to read n integers and compute the max of the even integers
21) Write a program to program to read an integer x. Compute the number of digits in x and store
it in n. Construct y by concatenating x for n times.
Example:
If x= 3152 then n= 4 and y=3152315231523152.
If x= 517 then n=3 and y=517517517

You might also like