product using adition

This is a discussion on product using adition within the C++ Programming forums, part of the General Programming Boards category; this program show at the last thread of the second page may encountered runtime error...as you input two numbers, the ...

  1. #31
    Notorious Turbo C killer blacksnake's Avatar
    Join Date
    Jan 2007
    Location
    philippines
    Posts
    50

    Exclamation end result:

    this program show at the last thread of the second page may encountered runtime error...as you input two numbers, the answer is not correct...is there something wrong with the program or the code?

    example:

    num1=3
    num2=5
    product=1549

    it should be:

    num1=3
    num2=5
    product=15

  2. #32
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,417
    Changes in red
    Code:
     
    // This program based on the old version of BORLAND C++
    #include <iostream.h>
    #include <conio.h>
    int main()
    {
    	int x;
    	int y;
    	int product = 0;
    	
    	cout<<"input first number:";
    	cin>>x;
    	cout<<"input second number:";
    	cin>>y;
    	
    	for(int i=0; i<x; i++)
    	{
    		product +=y;
    	}
    	
    	cout<<"Product is:"<<product;
    	getch();
    	return 0;
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #33
    Notorious Turbo C killer blacksnake's Avatar
    Join Date
    Jan 2007
    Location
    philippines
    Posts
    50

    Cool conclusion

    therefore, this program satisfies the problem...to all users behind it who help to solve...thank you....

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Matrix product
    By Cotizo in forum C++ Programming
    Replies: 4
    Last Post: 08-03-2008, 10:10 AM
  2. ...multiplication using stacks
    By iiwhitexb0iii in forum C Programming
    Replies: 1
    Last Post: 10-09-2006, 01:28 AM
  3. Product Keys
    By codegirl in forum Tech Board
    Replies: 6
    Last Post: 05-20-2006, 02:55 PM
  4. Microsoft Product Activiation loopholes
    By Liger86 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 07-08-2005, 05:20 PM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21