Question

    Write a for loop to print the odd numbers from 1 to 99 (inclusive)....

 

 

Write a for loop to print the odd numbers from 1 to 99 (inclusive). Print one number per line. There is no input from the user on this problem.

 

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

using namespace std;

int main()
{
for( int i=1; i<100;i++)
if(i % 2 == 1)
cout<<i<<endl;
return 0;
}

output:

1                                                                                                                               

3                                                                                                                               

5                                                                                                                               

7                                                                                                                               

9                                                                                                                               

11                                                                                                                              

13                                                                                                                              

15                                                                                                                              

17                                                                                                                              

19                                                                                                                              

21                                                                                                                              

23                                                                                                                              

25                                                                                                                              

27                                                                                                                              

29                                                                                                                              

31                                                                                                                              

33                                                                                                                              

35                                                                                                                              

37                                                                                                                              

39                                                                                                                              

41                                                                                                                              

43                                                                                                                              

45  

47                                                                                                                              

49                                                                                                                              

51                                                                                                                              

53                                                                                                                              

55                                                                                                                              

57                                                                                                                              

59                                                                                                                              

61                                                                                                                              

63                                                                                                                              

65                                                                                                                              

67                                                                                                                              

69                                                                                                                              

71                                                                                                                              

73                                                                                                                              

75                                                                                                                              

77                                                                                                                              

79                                                                                                                              

81                                                                                                                              

83                                                                                                                              

85                                                                                                                              

87                                                                                                                              

89        

91                                                                                                                              

93                                                                                                                              

95                                                                                                                              

97                                                                                                                              

99  

Add a comment
Know the answer?
Add Answer to:
    Write a for loop to print the odd numbers from 1 to 99 (inclusive)....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (java) Write a While loop that prompts the user for only even numbers. Keep prompting the...

    (java) Write a While loop that prompts the user for only even numbers. Keep prompting the user to enter even numbers until the user enters an odd number. After the loop ends, print the sum of the numbers. Do not include that last odd number. You should not store the numbers in an array, just keep track of the sum. Make sure to use a break statement in your code. You may assume that a java.util.Scanner object named input has...

  • Write a function to calculate the sum of the reciprocals of a series of odd numbers....

    Write a function to calculate the sum of the reciprocals of a series of odd numbers. The function will have one input and no output, with the input being the ending value for the series of odd values. Write the function definition statement Initialize a variable to zero. This variable will contain the sum of all the values. Create a for loop that loops over all odd numbers from 1 to the specified ending value. Inside the loop, add the...

  • Use Python3 Write a program that prints the numbers from 1 up to 105 (inclusive), one...

    Use Python3 Write a program that prints the numbers from 1 up to 105 (inclusive), one per line. However, there are three special cases where instead of printing the number, you print a message instead: 1. If the number you would print is divisible by 3, print the message: The dog of wisdom knows all about this number. 2. If the number you would print is divisible by 7, print the message: Hold on I have a meme for this....

  • Write a program that writes a series of random numbers to a file. Each random number...

    Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500 inclusive. 1.Use a file called randoms.txt as a input file and output file a. If you go to open the file and its not there then ask the user to create the file     and then quit 2. Ask the user to specify how many random numbers the file will hold. a.Make sure that the...

  • Write a for loop in MATLAB that stores the square root of the odd numbers from...

    Write a for loop in MATLAB that stores the square root of the odd numbers from 2 to 20.

  • Python 3 Write a program that calculates the factorial of the greatest odd number in a...

    Python 3 Write a program that calculates the factorial of the greatest odd number in a sequence of positive numbers (separated by spaces). The program must receive sequences of integers, one per line. The end of the input cases will be indicated by the number -1. For each line the program must print the factorial of the greatest odd number in each sequence. Note that for this question, there is always a greatest positive odd number in each line. Sample...

  • Write a program that will accept two numbers from the user. The program will then print...

    Write a program that will accept two numbers from the user. The program will then print all the numbers from the lowest number to the highest number. Make sure to include both numbers in the count. Also, it should not matter what order you input the two numbers. c++  

  • Write a while loop that repeatedly asks the user for a number until exactly 3 odd...

    Write a while loop that repeatedly asks the user for a number until exactly 3 odd numbers have been given. (Python)

  • Write a program that will loop ten times. In each iteration prompt user to enter an...

    Write a program that will loop ten times. In each iteration prompt user to enter an integer between -50&50. Print the input, keep a running sum of the inputs, and track the minimun and maximum numbers input. After the loop is complete, minimum number entered, maximum number entered, sum of all numberes entered, and average of all numbers entered. Format all output. Before running the loop, print the label "Input values: ". Within the loop, print value entered by user...

  • Write a program that check odd / even numbers (from number 1 to 100). Display the...

    Write a program that check odd / even numbers (from number 1 to 100). Display the results within an HTML table with 2 columns: one for odd number and one for even numbers. NUMBERS RESULTS ODD EVEN ODD 2 HINT: use <table> tags to create a table, <th> tags for 'Numbers' and 'Results'. Wrap code PHP inside HTML code. For example: <html> <title>CHECK ODD or EVEN</title> <body> <table> ?php echo "<tr><td>l</td><td>Odd</td</tr>"; </table> </body </html 2. Do the following steps in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT