Click here to Skip to main content
15,912,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: performance question Pin
Gary R. Wheeler20-Sep-03 14:13
Gary R. Wheeler20-Sep-03 14:13 
Generalpassing data structures Pin
Sirrius19-Sep-03 10:36
Sirrius19-Sep-03 10:36 
GeneralRe: passing data structures Pin
Michael Dunn19-Sep-03 11:11
sitebuilderMichael Dunn19-Sep-03 11:11 
GeneralRe: passing data structures Pin
Sirrius19-Sep-03 14:36
Sirrius19-Sep-03 14:36 
GeneralRe: passing data structures Pin
Sirrius19-Sep-03 13:00
Sirrius19-Sep-03 13:00 
GeneralWord wrap in Rich Edit and multiline edit Pin
insanely42019-Sep-03 9:07
insanely42019-Sep-03 9:07 
GeneralRe: Word wrap in Rich Edit and multiline edit Pin
David Pritchard1-Jun-04 14:21
David Pritchard1-Jun-04 14:21 
GeneralFinding the sum of all intergers between x & y Pin
pam128819-Sep-03 9:03
pam128819-Sep-03 9:03 
I am just learning how to use C++. I'm trying to create a simple program to do the following: A) allow the user to enter 2 integer values, B) determine the sum of all values between x & y, C) to show the product of x and y.

My code for steps A & C is working. My code for step B is not, I think I'm making it much more complicated then is required. Here is the sample code:

/* Write a program to find the sum of the integers between x & y. You
are then
to find the product*/

#include <iostream>
using namespace std;

int main ()
{
int x, y, z, s, p, h, sum;
s = 0;
sum = 0;

cout << "Please enter two integers" << endl;
cin >> x >> y;

p = x; //p is a place holder for the value x
z = x*y; // calculate the product

while (s <= y)
{

s = ++ x; // increment x by 1
h = p+s; // calucate the value of p + h
sum +=h; // compile the sum
cout <<"p = " << p << ". s = " << s << ". h = "<< h << endl;

}

cout <<"The product of " << p << " * " << y << " is "<< z << endl;

return 0;
}



Pam
GeneralRe: Finding the sum of all intergers between x &amp; y Pin
Tim Deveaux19-Sep-03 9:31
Tim Deveaux19-Sep-03 9:31 
GeneralRe: Finding the sum of all intergers between x &amp; y Pin
Tim Smith19-Sep-03 9:34
Tim Smith19-Sep-03 9:34 
GeneralRe: Finding the sum of all intergers between x &amp; y Pin
Tim Smith19-Sep-03 9:34
Tim Smith19-Sep-03 9:34 
GeneralRe: Finding the sum of all intergers between x &amp; y Pin
Harco19-Sep-03 9:40
Harco19-Sep-03 9:40 
Generalinhereted static member referencing Pin
Harco19-Sep-03 8:58
Harco19-Sep-03 8:58 
GeneralRe: inhereted static member referencing Pin
antlers19-Sep-03 12:07
antlers19-Sep-03 12:07 
GeneralExport CWnd* from DLL Pin
Mathias S.19-Sep-03 8:26
Mathias S.19-Sep-03 8:26 
GeneralMessages to derived CWnd object on CFormView Pin
Anonymous19-Sep-03 8:23
Anonymous19-Sep-03 8:23 
GeneralOnPaint() as opposed to OnDraw() Pin
ComboController19-Sep-03 8:14
ComboController19-Sep-03 8:14 
GeneralRe: OnPaint() as opposed to OnDraw() Pin
David Crow19-Sep-03 8:30
David Crow19-Sep-03 8:30 
GeneralDropDown Combo box background color issue Pin
sanjay zore19-Sep-03 6:49
sanjay zore19-Sep-03 6:49 
GeneralCString to LPCTSTR Pin
johnnyXP19-Sep-03 6:42
johnnyXP19-Sep-03 6:42 
GeneralRe: CString to LPCTSTR Pin
Dominik Reichl19-Sep-03 6:52
Dominik Reichl19-Sep-03 6:52 
GeneralRe: CString to LPCTSTR Pin
Alvaro Mendez19-Sep-03 12:01
Alvaro Mendez19-Sep-03 12:01 
GeneralRe: CString to LPCTSTR Pin
User 665819-Sep-03 6:52
User 665819-Sep-03 6:52 
GeneralRe: CString to LPCTSTR Pin
Binayak19-Sep-03 9:59
Binayak19-Sep-03 9:59 
GeneralRe: CString to LPCTSTR Pin
Michael Dunn19-Sep-03 11:15
sitebuilderMichael Dunn19-Sep-03 11:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.