Not Yet Answered # assistance needed for new programer

Discussion Starter unsure csurfer 422 csurfer 422 pspwxp fan 1 Discussion Starter unsure csurfer 422 Discussion Starter unsure csurfer 422 Discussion Starter unsure pspwxp fan 1 Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

0

I didnt think I could post it publically according to the rules. Here it is... please dont laugh.

```
/* sum of 10 numbers */ // This program computes the value of the sum of 10 numbers
#include <iostream.h>
int main ( )
{
// Define and initialize variables
float number, total, value of smallest variable;
int i = 1;
// Read in 10 numbers from the keyboard
while (i <= 10) {
if (number >1 and <99);
then (cin >> number); // read number
if ! (replace number) // read number
end if.
total = total + number; // total + number
i = i + 1; // i++
};
// Compute sum and print result;
Print smallest value;
// Exit program.
return EXIT_SUCCESS;
}
```

*Edited 3 Years Ago by Dani*: Formatting fixed

0

**Daniweb suggests you not to give away the codes directly to those who ask for it. **

Here you have a doubt about your work and you are free to post the part in which you have a doubt in and ask queries related to it. As long as you put in your effort you will always get help from this community.And ya read about code tags.

**You have put in a good effort but this is not a C++ program.As a matter of fact even your simple algorithm is incorrect**. Here are the problems :

```
/* sum of 10 numbers */
// This program computes the value of the sum of 10 numbers
#include <iostream.h>
int main ( )
{
// Define and initialize variables
float number, total, value of smallest variable;
int i = 1;
// Read in 10 numbers from the keyboard
while (i <= 10) {
if (number >1 and <99);
then (cin >> number); // read number
if ! (replace number) // read number
end if.
total = total + number; // total + number
i = i + 1; // i++
};
// Compute sum and print result;
Print smallest value;
// Exit program.
return EXIT_SUCCESS;
}
```

**Line 7 :** "value of smallest variable" is not a variable at all because variables can only contain alphabets and '_' and numbers(not in the beginning).**Line 11:**You haven even read the value of "number" and before that only you are checking it,the keyword "and" is used in program as "&&",you don't have a semicolon after the if condition(atleast not here in this problem).**Line 12 :**No keyword then recognised.

.

.

and so on ....

I sincerely applaud your effort and zeal in writing the program but you need to learn a lot. so TRY THESE.

0

I thought reading the number is what I was doing in line 12.

Yes you are reading the number in line twelve then what sense does it make to compare the number to be within some limits in line 11 itself....???

0

Yeah well, some of your "code" wasn't code at all, in fact, it was pseudo-code.

There is no such thing as "then" in C++. You evidently havn't learned C++, you've just seen pieces of code from places.

0

I am trying to learn... The instructor told us to use

If (condition)

Then (condition)

Else (condition) optional

end if.

0

If (condition)

Then (condition)

Else (condition) optional

end if.

Its something called pseudocode which tells you how to code ... but you need to code it according to language rules... that you haven done....

0

Is there a website I can go to or something? I am using my intro to C++ book and notes from class, but it all seems so foreign to me. I cant seem to make heads or tails of what I am suppose to do.

0

GOOGLE is your friend... try asking it and also this website is good ... And you are presently in a place where you can learn anything... DANIWEB.

0

I dont know if I know the right questions to ask to get the answers I need. I will keep trying though. Thank you for your help

0

If that is really true, then you have 2 options ahead of you.

#1:Either drop C++ and go become a doc.

#2: Or wait a bit until the lust for it develops in you.

Here's some sites you might find useful:

www.learncpp.com

www.cplusplus.com

and the almighty:

www.google.com

Oh yeah, most good students are self motivated to the subject they learn. They don't sleep in classes and don't simply stare at the pages instead of trying to make sense out of them.

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...