Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
i'm using microsoft studio standard. the problem i having is with this program.
write segments that accomplish each of the following:
a)calculate the integer part of the quotient when integer a is divided by integerb.
b)calculate the integer remainder when integer a is divided by integer b.
c)Use the program pieces developed in a) and b) to write a function that inputs an intger between 1 and 3277 and prints it as a series of digits, each pair of which is seperated by two spaces. for example , the integer 4562 should print as 4 5 6 2 and finally it takes an integer and print s it in reverse this is one program made up of segments how to combine. please help

It is pretty easy to tell you haven't attempted this assignment yet. a and b are trivial to anybody who has thought of the first things to come to mind in a problem like this. One line a piece is all it will take, but you have to sit down and try before people here are prone to help you. Try first, then come back and tell us what problems you are having and we will help you understand, but I've never seen anybody here do anybody's homework for free.
However, If you're a paying customer, we may be able to negotiate...:-)
-SN

the goal is not to have anyone do it for me. like you stated anyone willing to except cash would have accomplished this task for me . and besides i would just be shortchanging myself if i took that route. i'm a beginner at the c language and needed a little insight i didn't quite understand the question that's all but thanks for your insight and the feedback. even though you mistaken my post as an atempt to take the easy way out ;-(

wulf-
I understand that you are new to the c language (as I am) and just needed some direction. Nevertheless, it is still appropriate to try the assignment before asking people, as this will give you specific questions to ask. If you can do a simple "hello world" program, then you can do this assignment.Here are some questions to lead you in the right direction:
when a and b are ints, what does a/b do?
what does a%b do?What if a and b are floats or doubles, what do the same operations do?
Mathematically (forget about programming), how do you isolate one digit of an integer?
Hope this helps,
SN

thanks but you can't seem to get away from saying i tried to take the easy way out. i e-mailed my instructor but with no reply yet. this is what i had when i posted the message.
/* Intro to programming in C.
Chap 5 ex 5_22 & 5_28.c Program will calcuate the integer
part of the quotient, calculate the remainder and display the output
in two ways seperate by spaces and in reverse order */#include
int a,b;int main()
{
printf("Enter first number:");
scanf("%d", &a);
printf("Enter second number:");
scanf( "%d", &b);
printf( " %2d", a/b);
printf( " %2d", a%=b);
printf("\n");
return 0;}
it's c) i'm stuck on an integer between 1 7 32767 i'm not sure if it's a random statment or user input. not clear what the question using a0 and b). maybe i'll just wait for my instructors reply so it doesn't seem as if i'm cheating in your opinion s/n :-(

wulfg74,
There would be no confusion if you posted what you have above as the first post. By doing that, we see that you have, in fact, tried the program and we will be more willing to help. If you want to recieve help, be specific, and be sure to include source code.
Kevin.
(Is there something wrong with using proper grammar and punctuation on this forum?)

wulf-
Thank you for posting your code and being more specific. I'm sorry I've offended you, I did not mean to imply you were cheating. I am in school as well and have asked for help on homework on several occasions. In the future, any confusion would be avoided by following kev's advice.What are you trying to do with this statement?
a%=b
I think you just want the remainder of a/b, so there is no need for the equal sign (unless this is a c++ subtlety I don't know about.)As for (c), this is a reasonable question to ask in this forum.
To isolate a digit from an integer, you can use the mod and division operators:
1st digit of n=n%10/1
2nd digit of n=n%100/10
3rd digit of n=n%1000/100
...
nth digit of n=n%10^n/10^(n-1)This should be enough to get you the first part of C. The second part is a little tougher. There are several algorithms you could adopt, but where you're at it may be best to first determine how many digits there are in the integer, which can be done in a simple loop, then you can use another loop to start from the nth digit and output each digit until you get to digit 1.
There was a post on this forum less than a week ago on how to find the number of digits in an int.
Hope this helps,
SN

s/n thanks for all of the advice sorry for not being more specific with my problem.
and for kev,
the misprints are just minor errors. didn't have enough time to proof read the post, but since your so good at grammar figure this one out : byte m e j u rk!

Now, now, no need to get upset. *giggle*
Don't worry, you're not the only one. I see far too many posts where the original 'poster' just botches their post by the absence of any punctuation or grammar whatsoever. Some are even to the extent of where the post is completely unreadable. I didn't mean to point you out necessarily, although you do fall into the category - your post just reminded me.
My apologies :DKevin.

![]() |
Javascript pinger
|
Need Advice (Using Java S...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |