Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
P

pam1288

@pam1288
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Finding the sum of all intergers between x & y
    P pam1288

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

    C / C++ / MFC c++ tutorial learning
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups