c++

Write the 6- in- one Program for
-Finding solution of a Quadratic equation
-Finding solution of a Simultaneous equation
-Finding sum of all even numbers between two given values
-Finding the sum of all odd numbers between two given values
-Finding the sum and average of any given numbers
-Finding factorial of a number.
And why, pray tell, would I do this for you? Especially for free.
closed account (z05DSL3A)
No.
Isnt this a forum for begginers? I asked that if any one could help me...i wanna know more in c++
It is. What it is not, however, is a forum for us to do your homework for you.
Thats not a home work...am tryna workout somethng beta for my own...thats why i asked, any let it not be an issue. Lets drop t, ama find someone else to help me.
What these guys are saying: Make an effort. Try yourself. Got stuck? Post a very specific question on the item you got stuck at. That is the world different than what you posted. You posted the equivalent of: Give me code that does all this. Why would we give you the code out of the blue?

And that's the point behind the answers you are getting.

There is a sticky thread on top of this forum called "Welcome -- read before posting!". You did not read it, obviously. Here it is: http://www.cplusplus.com/forum/beginner/1/ .
ok
Your problem looks like a lot of fun, so please let us know if you get stuck.
so far this is what i have worked out on the third question...."Finding the sum of all even numbers between two given values."

#include <iostream>

using namespace std;

int main()
{
int numb1;
int numb2;
int sum;

cout <<"Enter the First Number and Second Number" << endl;
cin>>numb1>>numb2;
for( numb2=numb1; numb1<=numb2; numb1+=2 )
sum += numb1;

if( numb1 = numb1%2==0 )
{
numb1: numb1+1;
}
else if( numb2 = numb2%2==0)
{
numb2: numb2-1;
}
else
{
cout<<"Invalid Entry";
}
return 0;
}
In your FOR loop, you are using numb2 to iterate and to compare at the same time. Cannot be done like this. You need a third variable. Basically, you must not touch the values of numb1 and numb2 because those are given by the user.

for (int i = numb1; i <= numb2; i += 2)

BTW, please always format your code by using code tags: [code]//Place the code here. [/code]

One more thing. If you start looping from i = numb1, and then advancing 2 each time, are you looping through even or odd numbers?
through even numbers.
Really? Sure about that? What happens if numb = 1???? What values will 'i' go through? Are they even?
Last edited on
it wont go through....i have tried. so what should i do?
Ok, a bit more help. See http://ideone.com/sfzYt.

The code output is shown below the code. The numbers input were 5 and 23.

Compare the differences between your code and mine. Also find out why the total is INCORRECT and fix it. Hint: The if() in line 18 contains the tool to fix it. After all, if the if() can determine there was a problem, why not use the same detection mechanism to PREVENT the problem before it occurs?
See http://ideone.com/sfzYt. it wont go through....
That's my code. Are you serious?? Why are you thowing back at me my own code? I know exactly what the problem is. Saying "it wont go through" can only get you so far, and as far as I'm concern we are there already.

Understand my code first, and understand the subtle differences between mine and yours. After that, figure out why the total is wrong for certain inputs of numb1.
@webJose I think he meant he can't open the link, there's a stray '.' in it, should be: http://ideone.com/sfzYt
Ah, could be. This forum's parser will append to the link the period. Still, I think the OP could be more assertive stating the problem(s).
Last edited on
Topic archived. No new replies allowed.