2 Replies - 1026 Views - Last Post: 15 November 2009 - 08:20 PM Rate Topic: -----

#1 origami77  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-November 09

Concatenating digits

Post icon  Posted 14 November 2009 - 10:28 PM

I want to combine numbers:
EXAMPLE:
#include <iostream>
#include "stdafx.h"
using namespace std;

int main()
{
int x;
int y;
cout << "Enter a #" << endl;
cin >> x;
cout << "Enter a #" << endl;
cin >> y;
int xandy = //how would i make it equal (if x=3, and y=4) 34?
cout << xandy << endl; // write out 34 on the screen
}




Thank you in advance!

origami77

This post has been edited by origami77: 14 November 2009 - 10:29 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Concatenating digits

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Concatenating digits

Posted 14 November 2009 - 10:31 PM

Cast "x" and "y" into strings then concatenate the strings.

More here
http://www.cplusplus.../string/string/
Was This Post Helpful? 0
  • +
  • -

#3 freeAccount  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-November 09

Re: Concatenating digits

Posted 15 November 2009 - 08:20 PM

Why don't you multiply x*10 and add y to it

This post has been edited by freeAccount: 15 November 2009 - 08:22 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1