Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 510
  • Last Modified:

Char Array in C#

Hi,

I am beginner to C#. Can someone show me an example where program is accepting two numbers upto 256 digits using char arrays and then adding those two numbers using C#.

I would really appreciate help on this.

Arpita
0
aparmar
Asked:
aparmar
1 Solution
 
Razzie_Commented:
Sounds like homework. Why do you want it done that way?
0
 
aparmarAuthor Commented:
yes it is a homework. Its program that accepts two numbers of 256 digits each and after accepting two numbers it adds those two. Is there another way of doing it?

Thanks

arpita
0
 
aparmarAuthor Commented:
I can write simple program declaring two integer variable but my only problem is 256 digits limit.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AvonWyssCommented:
Well, use a byte - not a char. A char in the .NET world is unicode and thus not 8 bits anyways, apart from not being a numeric type alltogether.
0
 
a_goatCommented:
OK, basically don't think of it as character arrays.  Use two strings to read in the values.  Then you have to remember your old grade school addition:

345678
+24601
---------
370279

Just start from the end of each string and add the two numbers together (you can convert the characters to numbers in a number of ways, my favorite is (byte)NextCharacter - 48)  Don't forget to handle the case where you have to carry a one over to the next column.  Build your result string as you go.

Was that vague enough to pass EE guidelines yet specific enough to help?
0
 
aparmarAuthor Commented:
Thanks goat. This helps. It answers my question. all I needed was a guideline not a solution.
Thank You.
0
 
AvonWyssCommented:
Goat solved the question... see author comment 10/13/2004 04:52PM CEST
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now