Not Yet Answered # joining numbers

SpS 34 Discussion Starter jvignacio SpS 34 madhuri_mi Nick Evan 4,005 dubeyprateek 26 OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...

0

Input is always three numbers of two digits or it can be 'n' numbers consisting any number of digits?

0

It can be any numbers and as many numbers and digits...

like 1 2 3 = 123

or 34 45 56 67 = 34455667

know what i mean ?

0

It can be any numbers and as many numbers and digits...

like 1 2 3 = 123

or 34 45 56 67 = 34455667know what i mean ?

Well then you have to store it in a string. Because there's a limit of integers. Just accept the input as string and merge it.

0

Hi guys, just wondering, how would i go about joining numbers together to form one integer..

example.. number 70 54 34

would end up being 705434..

thank u for your ideas...

Hi I have the solution here... Just see is it your required one...

Plz reply me back.....

```
#include<stdio.h>
int main()
{
int a[30],i=1,num,cnt=0,num1;
printf("Enter the numbers....\n");
printf("If dont want to continue enter 9999\n");
while(1)
{
scanf("%d",&num);
if(num==9999)
break;
a[i]=num;
i++;
cnt++;
}
num1=a[1];
for(i=2; i<=cnt; i++)
{
if(a[i]<=9)
{
num1=num1*10;
num1=num1+a[i];
}
else if(a[i]<=99 && a[i]>10)
{
num1=num1*100;
num1=num1+a[i];
}
else if(a[i]<=999 && a[i]>99)
{
num1=num1*1000;
num1=num1+a[i];
}
}
printf("%d",num1);
return 0;
}
```

0

Sorry, but that won't work:

It can be any numbers and as many numbers and digits...

your program only accepts numbers <=999:

`else if(a[i]<=999 && a[i]>99)`

I would go with strings too.

Regards Niek

0

It can be any numbers and as many numbers and digits...

like 1 2 3 = 123

or 34 45 56 67 = 34455667know what i mean ?

What do u think about intiger overflows?

int can store maximum of 2,147,483,647.

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.

This is the result of previous question answered :

code for the listbox - datagridview interaction

At the top of the code ...

Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.

btn_addline :

`Private Sub btn_addline_Click(ByVal ...`