Not Yet Answered # Urgent Help Need!!

wildgoose 420 __avd 1,826 firstPerson 761 Discussion Starter chikool Discussion Starter chikool wildgoose 420 Discussion Starter chikool wildgoose 420 Discussion Starter chikool kartel Discussion Starter chikool kartel gokhantiriviri dgr231 22 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

A for loop is like a while loop, note the components below

```
for (int m = 0; m < 4; m++ )
int m = 0;
while ( m < 4 )
{
m++ }
```

In your code you have the initializer int m = 0

You have the comparison, but no definition for <i>

and you really should have parenthesis around the (i%2)==0

Finally your other problem m*m=i I think you may have

meant m*=i. You are doing an assignment m*m is not an assignment!

for (int m=0;i<4 && i%2==0; m*m =i)

0

Welcome chikool,

You must read,

1.Homework policy

2.How to post source code?

3. Title of thread must reflect your question.must read article - How To Ask Questions The Smart Way

0

"m*m =i "

Lets see , let m = 5, then

```
5 * 5 = i
---------------
5 * 5 = 0 /// 25 = 0 // = false
5 * 5 = 1;// 25 = 1 // false
5 * 5 = 2;// 25 = 2 // false
5 * 5 = 3//25 = 3 //false
// so on until i = 25, then it would be true, but has no effect on the
loop
```

Did that make sense? Obviously m*m =i , is not what you

want to do. I think you are looking for is what wildgoose posted.

0

```
if(N<4&&(N%2)==1)
{
cout<<"The program can not be executed "<<endl;
}
else(N>4&&(N%2)==0);
{
result=N*N;
cout<<"Multiplication of all positive even numbers which are greater than N: "<<result<<endl;
}
```

What i am trying to achive is when i enter the 4 numbers, all the positive even numbers greater 4 entered by a user should be multiplied by each other and say if only one positive even number is been entered by the user then that should multiplied by 1.

And if the user does not enter any prositive even number then the program should give and error.

0

`if(N<4&&(N%2)==1) { cout<<"The program can not be executed "<<endl; } else(N>4&&(N%2)==0); { result=N*N; cout<<"Multiplication of all positive even numbers which are greater than N: "<<result<<endl; }`

What i am trying to achive is when i enter the 4 numbers, all the positive even numbers greater 4 entered by a user should be multiplied by each other and say if only one positive even number is been entered by the user then that should multiplied by 1.

And if the user does not enter any prositive even number then the program should give and error.

0

```
nProduct = 1
for (int i = 0; i < 4; i++)
if ((ary[i] > 4) && !(ary[i] & 1))
nProduct = nProduct * ary[i];
endif
endfor
if (1 ==nProduct) then error
```

0

Hi,

Thanks for the reply, but we are not to use ary, then how would this be done.

0

```
nProduct = 1
for (int i = 0; i < 4; i++)
input v
if ((v > 4) && !(v & 1))
nProduct = nProduct * v;
endif
endfor
if (1 ==nProduct) then error
```

0

```
{
nProduct = 1;
for (int i = 0; i < 4; i++)
{
if ((N > 4) && !(N & 1))
nProduct = nProduct * N;
cout<<"Multiplication of all positive even numbers which are greater than N: "<<nProduct<<endl;
}
}
if (1 ==nProduct)
{
cout<<"The program can not be executed "<<endl;
}
}
```

This iis the code i have written and even after what you have given i am unable to get my outcome.

0

hey the correct question is :::: multiplication of all the positive even numbers which are greater than N. if 1 even number greater than N is entered from the keyboard the entered number should be multiplied by 1. if no even number greater than N are entered, the program should display an approriate message.

0

The user will enter the 4numbers and it will display on the screeen, if you see i am getting the user to enter to numbers...

0

but the id condition says that

if ((N > 4) && !(N & 1))

what is n & 1 is it says that its positive ????

0

I have the same question for my assignment as well.. :) CQu sydney..

Anyone completed so far?

0

Hey guys,

If I'm understanding your problem correctly, then it seems to me like you want the program to look similar to the following outline:

```
#include <iostream>
using namespace std;
int main(void)
{
int nUserNum;
//set the next variable equal to 1 so that if the user enters
//only one applicable number, it is multiplied by 1
int nTotalNum=1;
for(int i=0;i<4;i++)
{
//ask user to enter their number and store it in nUserNum
if(nUserNum > 4 && nUserNum % 2 == 0)
{
//multiply nTotalNum by nUserNum and store in
//nTotalNum
}
//this next part insures that the user receives an error
//message if they don't enter an applicable number
if(i == 3 && nTotalNum == 1)
{
//give user error message
}
}
//Display the user's total using the nTotalNum variable
return 0;
}
```

Hopefully that sets you guys on the correct track.

-D

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 ...