C Beginner - Need Help

• 10-13-2010
.C-Man.
C Beginner - Need Help
Hey everyone. I'm new to this site as well as I am C Programming. My instructor is moving pretty quick so I'm getting lost in some things that we're learning. If anyone can help me figure this out, it would be much appreciated.

"1. Write a C Function named as sumIntegralDigitVersionAYourName() that will ask the user for a floating point-point value and will

a. Print the sum of the 1-digit and the 100-digit of the integral part, and
b. Return the sum of the 1-digit and the 100-digit of the integral part.

2. Write a C function named as sumFractionalDigitVersionAYourName() that will ask the user for a floating-point value and will then

a. Print the sum of the first-most-significant digit and the third-most-significant digit of the fractional (decimal) part, and
b. Return the sum of the first-most-significant digit and the third-most-significant digit of the fractional (decimal) part

3. Write a C program with main() calling the above 2 functions; name your program as cis26Fall2010YourNameProblem5.c and also provide a sample output of your program. "

It's not that I have a problem with the proper syntax or anything. It's more that I don't know how to use code to find the decimal parts, significant digit, etc. I'd appreciate any help.
• 10-13-2010
Salem
Do you have examples of input + expected output?

Normal double variables typically have 15 decimal digits of precision, so I don't know where this 100-digit idea is coming from.

If you're looking at say
1234556789009496365726524504869727294025.093579267 9257295729525 (only much larger)
then you need to be looking at string processing.
• 10-13-2010
rogster001
Quote:

sumIntegralDigitVersionAYourName()
Quote:

cis26Fall2010YourNameProblem5.c
I think your tutor failed the 'naming coventions 01' course myself mate, them's some ugly headache-inducers right there.

Why don't you post up any code you have already, you will get more help

EDIT:

Quote:

so I don't know where this 100-digit idea is coming from.
Maybe it refers to the second 0 after decimal point? Apart from that the question is not exactly clear
• 10-13-2010
.C-Man.
I'll use the number 123.456 as an example. The 1 = the "1-digit", the 3 = "100-digit", the 4 = the "first-most-significant-digit", the 6 = "the third-most-significant-digit". Yeah, my instructor makes this quite confusing with the names he has for the functions but... there's not much I can do.
• 10-13-2010
CommonTater
Quote:

Originally Posted by .C-Man.
I'll use the number 123.456 as an example. The 1 = the "1-digit", the 3 = "100-digit", the 4 = the "first-most-significant-digit", the 6 = "the third-most-significant-digit". Yeah, my instructor makes this quite confusing with the names he has for the functions but... there's not much I can do.

Sounds like your instructor has more than that to work on...

In the number 123.456

The "1 digit" is the 3, not the 1.
The "100 digit" is the 1 not the 3.

It's hundreds, tens, ones ... not the other way around.
• 10-13-2010
.C-Man.
Quote:

Originally Posted by CommonTater
Sounds like your instructor has more than that to work on...

In the number 123.456

The "1 digit" is the 3, not the 1.
The "100 digit" is the 1 not the 3.

It's hundreds, tens, ones ... not the other way around.

That's right. I think I misread my own question myself, lol. Anyway, I don't know how to find any of those digits. This is all confusing for me.
• 10-13-2010
CommonTater
Ok, let me give you one hint and you can take it from there...

int x = (int)(( y / 100) % 100 );

Should split out the hundreds digit for you.
• 10-13-2010
.C-Man.
Quote:

Originally Posted by CommonTater
Ok, let me give you one hint and you can take it from there...

int x = (int)(( y / 100) % 100 );

Should split out the hundreds digit for you.

Well it should be int x = (int)(( y / 100) % 10 ); actually because if I typed in a number like 1234.123 it would print 12 as the hundred digit. But you really helped me understand that, thanks.
• 10-13-2010
CommonTater
Hmmmmm.... You're right and you're welcome. LOL.