Solved

Char Array in C#

Posted on 2004-10-12
12
503 Views
Last Modified: 2008-03-10
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
Comment
Question by:aparmar
12 Comments
 
LVL 8

Expert Comment

by:Razzie_
ID: 12290443
Sounds like homework. Why do you want it done that way?
0
 

Author Comment

by:aparmar
ID: 12290587
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
 

Author Comment

by:aparmar
ID: 12290644
I can write simple program declaring two integer variable but my only problem is 256 digits limit.

0
Industry Leaders: 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!

 
LVL 14

Expert Comment

by:AvonWyss
ID: 12290696
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
 
LVL 3

Accepted Solution

by:
a_goat earned 125 total points
ID: 12294649
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
 

Author Comment

by:aparmar
ID: 12298767
Thanks goat. This helps. It answers my question. all I needed was a guideline not a solution.
Thank You.
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 12512513
Goat solved the question... see author comment 10/13/2004 04:52PM CEST
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question