Question: No.1 Problems: 1. Write a program to find out (the hard way, by counting them) how many of the numbers from 1 to 10 are
Problems: 1. Write a program to find out (the hard way, by counting them) how many of the numbers from 1 to 10 are greater than 3. (The answer, of course, should be 7.) Your program should have a loop which steps a variable (probably named i) over the 10 numbers. Inside the loop, ifi is greater than 3, add one to a second variable which keeps track of the count. At the end of the program, after the loop has finished, print out the count 2. a) Write a program to print the numbers from 1 to 10 and their squares: 10 100 b) Write a program to compute the average of the ten numbers 1, 4, 9, ., 81, 100, that is, the average of the squares of the numbers from I to 10. (This will be a simple modification of Exercise 2a: instead of printing each square as it is computed, add it in to a variable sum which keeps track of the sum of all the squares, and then at the end, divide the sum variable by the number of numbers summed.) 3. Write a program to print the first 10 Fibonaci numbers. Each Fibonacci number is the sum The sequence starts out 0, 1,1, 2, 3, 5, 8
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
