Thnx and regards
acardiac

Q.1. Write a program that accepts a nonnegative integer n and base b and display the digits of base-b representation (in reverse order) for each integer using a do-while loop. You may assume that each base is in the range 2 through 16. Use switch statement to display the symbols A, B, C, D, E, and F for 10, 11, 12, 13, 14 and 15 respectively for all the bases above 10. The program must be executed repeatedly for different integers and bases as long as the user wants.

Q.2. The proper divisors of an integer n are the positive divisors less than n. a positive integer is said to be deficient, perfect, or abundant number if the sum of its proper divisors is less than, equal to, or greater than the number, respectively. For example, 8 is deficient because its proper divisors are 1, 2, and 4, and 1 + 2 + 4 < 8; 6 is perfect because its proper divisors are 1, 2, and 3, and 1 + 2 + 3 = 6; 12 is abundant because its proper divisors are 1, 2, 3, 4, and 6, and 1 + 2 + 3 + 4 + 6 > 12. Write a program that takes an integer n and classifies each integer between n and n + 20 as being deficient, perfect or abundant

## All 6 Replies

It's hard to help if you don't ask a question. Do you have any code that's not working right or do you not understand parts of the problems? Or did you just want someone to do your homework for you? ;)

The second can be solved very easily with a for loop alone

for ( i = 1 ; i < n / 2 ; i++ )
if ( !(n % i )) sum += i ;

While the first, you may use the follwing:

1) Get the unsigned number 'n'( and duplicate it) & the base 'b' that should be used.
2) perform 'n' modulo 'b' & get each digit the same way
3) Use switch case or what ever you want to find the corresponding digit in base 'b'.
( My advice dont use switch case. Use the nature of ascii codes for your advantage )
4) print the characters that you should have stored in step 2 in reverse order

Thanx to all who replied in a positive manner.
What if i needed a little help in my assignment.
there is no loss in helping a newbie achieve something
maybe someday you will also need some help from someone.
thanx anywayz fot the help

Hey!!! Show some effort! even if your a newbie, you should exert some effort!

> What if i needed a little help in my assignment.
Edward is happy to help as long as the help doesn't amount to doing it for you. I'm sorry you perceived Ed's reply as not being positive, it was a request for more information in order to better help you.

Thanx there!
I just wanted help and also came here
because of the fact that i dont even know
the basics of programming and have now
taken admission in Masters program in computer sciences.
So if somebody can help me in achieving
this i shall be very thankful!
Advice and help is yours and effort is mine!
Have a nice day and Alwayz smile!
Asim Ilyas

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.