write a program based on looping statement.
Answers
def increment(salary):
salaries = []
new_salary = salary
for _ in range(5):
new_salary *= 1.1
salaries.append(round(new_salary, 2))
return "\n".join([f"Year {idx + 1}: {salary}" for idx, salary in enumerate(salaries)])
print(increment((salary := float(input("salary: ")))))
You didn't mention what the program should do, so I added this program which uses a for loop.
Answer:
#include < stdio . h >
#include <conio . h >
int main ( )
{
int num=1 ; / / i
nitializing the variable
while ( num <=10 ) / /w
hile loop with condition
{
print f ( "%d \ n ", num );
num ++;
/ / incrementing operation
}
return 0 ;
}
Output:
1
2
3
4
5
6
7
8
9
10