Not Yet Answered # combine two intergers

pheininger 5 Discussion Starter megaman656 VernonDozier 2,218 Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...

0

for example, i want to combine two number 6 and 8 and it will equal 68. is this possible in C?

`int a = 6, b = 8,c; c=ab;`

and c will = 68.

Yes it is possible, but not the way you have shown. Your assignment statement assigns the value of the variable ab to the variable c. The variable ab has not been defined.

It also depends a lot on what you mean by combine. What do you want to happen if a==56 and b==24? Similarly for a==25 and b==5? Or a=='6' (the character displayed as 6) and b=='8'?

So please explain what the "larger" problem or context is?

0

what i mean is for example

a=256 and b=10

i want to combine them so that they would be 25610.

or

a=19, b=20

it would combine to 1920.

is this possible?

0

Yes, it's possible. It would be something like this...

```
int multiplier = /* multiply by 10, 100, 1000, whatever based on the number of digits in b */
int combine = (multiplier * a) + b;
```

Your job is to figure out how many digits b has. There are a few ways to do that. log10 and pow from cmath might help, and / or use the / and % operators in a loop to figure it out or write your own helper function(s). Or perhaps use the itoa function if available or the snprintf(or sprintf if you're careful) function to turn b into a string, then take the length of that string.

http://www.cplusplus.com/reference/clibrary/cmath/

http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/

http://libslack.org/manpages/snprintf.3.html

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

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...