Compaq Visual Fortran Professional Edition 6.6 (QB-5UDAB-PA) for PC Logo

Related Topics:

Posted on Oct 30, 2010

Write a program to sum of all even integer numbers

1 Answer

Anonymous

Level 1:

An expert who has achieved level 1.

MVP:

An expert that got 5 achievements.

New Friend:

An expert that has 1 follower.

Hot-Shot:

An expert who has answered 20 questions.

  • Contributor 24 Answers
  • Posted on Nov 24, 2010
Anonymous
Contributor
Level 1:

An expert who has achieved level 1.

MVP:

An expert that got 5 achievements.

New Friend:

An expert that has 1 follower.

Hot-Shot:

An expert who has answered 20 questions.

Joined: Mar 30, 2010
Answers
24
Questions
0
Helped
11089
Points
43

#include <iostream>
using namespace std;
int main ()
{
int num = 0, i = 1, sum = 0;
cout << "Enter a positive integer: ";
cin >> num;
while (i <= num)
{
sum += i;
i++;
}
cout << "The sum is " << sum << endl;
return 0;
}

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

0helpful
1answer

The Sum of 2 integers from 1 to 9 that are four consecutive numbers. Show that either one or three of the numbers on the counters were even

I need some help here. If we take the sum of 2 integers from 1 to 9, and they can be the same number, the maximum number is 18. I don't know how you are supposed to get four consecutive digits, unless you pad the number with zeros. Am I missing something?

Good luck,

Paul
0helpful
1answer

Find the smallest two consecutive even integers such that three times the smaller is at least 19 more than the sum of the two integers

Let x be the smallest number.
Let x + 2 be the other number (consecutive even integer)

Now to translate the rest;)
three times the smaller 3(x)
19 more -19
sum of the two integers - (x) +( x+2)

Pulling it together,
3x -19 = x + x +2
collect like terms
3x - 19 = 2x + 2
Put all the constants on one side by adding 19 to both sides.
3x - 19 +19= 2x + 2 + 19
3x = 2x +21
Subtract 2x from both sides to have all the x's on one side.
3x - 2x = 2x +21 - 2x
x = 21
The other number is 21 + 2, or 23
Check:three times the smaller = 3 x 21 = 63
sum of the two integers = 21 + 23 or 44
is 63 at least 19 more than 44






0helpful
1answer

Consecutive even integers

38.
The three numbers are 34, 36, and 38.
0helpful
1answer

Sum of consecutive positive integers

Here's a simple (and inefficient) 35s program. It simply goes through a loop 25 times, adding up the numbers.

A001 LBL A
A002 25
A003 STO A
A004 0
A005 RCL+ A
A006 DSE A
A007 GTO A005

The sum of the first N positive integers can be calculated more efficiently as N(N+1)/2 .
6helpful
1answer

Consecutive even integers

The two numbers are 32 and 34. The rest is your homework, you do it.
0helpful
2answers

I want first 20 Armstrong numers


1
2
3
4
5
6
7
8
9
153
370
371
407
1634
8208
9474
54748
92727
93084
548834
0helpful
1answer

What are the three consecutive integers whose sum is 378?

Let X be the lowest of the 3 integers
The sum of the 3 integers can be represented as X + (X+1) + (X+2).
Set this sum equal to 378 and solve for X.
X + (X+1) + (X+2) = 378
3X + 3 = 378
3X = 375
X = 125
Since X is the lowest of the 3 integers the other 2 will be X+1 and X+2 or 126 and 127.

Therefore, the answer is 125, 126 and 127
0helpful
1answer

Pls. help me

Q.2#  Dim n, sum as Double
Dim i as Integer
n=100
sum=0

for i=1 to n
sum=sum+1/n
next i

Q.3#  Dim sum as Double
sum=0
for i=1 to 99
if i%2 <> 0 then sum=sum+i end if
next i
0helpful
2answers

Armstrong problem

could you give me more info plz
Not finding what you are looking for?

135 views

Ask a Question

Usually answered in minutes!

Top Compaq Computers & Internet Experts

Grand Canyon Tech
Grand Canyon Tech

Level 3 Expert

3867 Answers

Brad Brown

Level 3 Expert

19187 Answers

ExpressFiX
ExpressFiX

Level 2 Expert

691 Answers

Are you a Compaq Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...