answersLogoWhite

0


Best Answer

101

User Avatar

Elza Larkin

Lvl 10
3y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

First create a list of the number 0-100. (probably using for i in range(100) etc.)

Then run through this list checking if there is a remainder when you divide by 2.

(If there isn't a remainder the number is even. If there is then the number is odd.)

If there is a remainder of the number you are currently checking add it to a separate list.

You will then have a list of all the odd numbers.

Create a total that at first equals zero. Then run through the list of odd numbers constantly adding each one to the total.

At the end of this process the total will equal the sum of all of the odd numbers from 0 to 100.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

printf ("sum of 1+3+...+97+99=%d\n", ((1+99)/2)*50);

1+2+...+99+100=5050

1+3+...+97+99=2500

2+4+...+98+100=2550

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

You won't directly find such a program here. That does sound suspiciously like a homework assignment. You might find someone who can give you some ideas, though.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you give me a program that will compute and display all the sum of odd numbers from 1-100?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the 4-binary number assoiated with the hexadecimal symbol C?

0xc = 1100 Hexadecimal digits use exactly 4 binary digits (bits). The 0x0 to 0xf of hexadecimal map to 0000 to 1111 of binary. Thinking of the hexadecimal digits as decimal numbers, ie 0x0 to 0x9 are 0 to 9 and 0xa to 0xf are 10 to 15, helps with the conversion to binary: 0xc is 12 decimal which is 8 + 4 → 1100 in [4 bit] binary.


If its 1100 mst time what time is in ist?

If_its_1100_mst_time_what_time_is_in_ist


How to draw a Flowchart of swaping of two numbers in c plus plus?

A proper flow chart for that purpose can't be depicted here, but the code would work as follows: Given the two numbers, A and B: C = A; A = B; B = C; ~if~ the numbers are integers, longs, or other types on which you can use an XOR operator (ie. not floats, doubles, etc.), then you could also do it this way: A ^= B; B ^= A; A ^= B; That is because of the way the binary XOR works. For example, let's say "A" is equal to to 12 and "B" is equal to 7: A = 1100 B = 0111 If you run through those operations: first A ^= B, now: A = 1011 B = 0111 Now B ^= A: A = 1011 B = 1100 and again, A ^= B: A = 0111 B = 1100 or in decimal, A now equals seven, and B now equals twelve. Again, this will only work with fixed point values such as integers. You can't use it on floats.


How do you convert A B C in binary code?

A = 1010 b = 1011 c = 1100


Show calculations on how to convert binary to hexadecimal?

Quick reference chart for converting Hexidecimal to Binary numbers: Hex Binary 0.... 0000 1.... 0001 2.... 0010 3.... 0011 4.... 0100 5.... 0101 6.... 0110 7.... 0111 8.... 1000 9.... 1001 A.... 1010 B.... 1011 C.... 1100 D.... 1101 E.... 1110 F.... 1111