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

Recommended Answers

All 6 Replies

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

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 ?

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 ?

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.

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

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

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 ?

What do u think about intiger overflows?
int can store maximum of 2,147,483,647.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.