Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > please help me to correct/ build/ complete the program

Reply
Thread Tools

please help me to correct/ build/ complete the program

 
 
jyck91@gmail.com
Guest
Posts: n/a
 
      03-21-2007
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
main()
{
float num;
int i, temp, remainder, baseM, j;
printf("Enter a number:");
scanf("%f",&num);
printf("Enter the base that you want:");
scanf("%d",&j);
if (temp > baseM){
temp = num;
remainder = temp % baseM;
temp = temp / baseM;
}
for ( i=num; i>=0; i++)
remainder[i] = remainder;
printf("%s",remainder[i]);
system("PAUSE");
}

****** this is a base conversion program(part 2)
I want to convert the base10 number to baseM( first in 2-9)
eg. 5(10)------>101(2)
eg. 10(10)-----> 22(4)
******the above program can not run and there are some mistake that i
can't find out
please help me to correct them

******Since i need to hand in it tomorrow , please help me as soon as
possible
thank you for your help

 
Reply With Quote
 
 
 
 
osmium
Guest
Posts: n/a
 
      03-21-2007
<(E-Mail Removed)> wrote:

No fix. Just some observations.

> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <math.h>
> main()
> {
> float num;
> int i, temp, remainder, baseM, j;
> printf("Enter a number:");
> scanf("%f",&num);


Why don't you get a program that works just for positive integeres first?
You can do the floating thing later.


> printf("Enter the base that you want:");
> scanf("%d",&j);
> if (temp > baseM){


temp has an unknown value, but you use it in a comparison. Why do that?

<snip>


 
Reply With Quote
 
 
 
 
mark_bluemel@pobox.com
Guest
Posts: n/a
 
      03-21-2007
On 21 Mar, 13:23, (E-Mail Removed) wrote:
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <math.h>
> main()
> {
> float num;
> int i, temp, remainder, baseM, j;
> printf("Enter a number:");
> scanf("%f",&num);


1) scanf is generally not a good idea for a beginner.
2) why are you trying to work with a float?
3) In addition you haven't flushed output, or finished your prompts
with newlines, so there's no guarantee they'll be seen.

> printf("Enter the base that you want:");
> scanf("%d",&j);
> if (temp > baseM){


neither temp nor baseM have been assigned values

> temp = num;
> remainder = temp % baseM;
> temp = temp / baseM;
> }
> for ( i=num; i>=0; i++)
> remainder[i] = remainder;


remainder is not an array

> printf("%s",remainder[i]);
> system("PAUSE");
>
> }
>
> ****** this is a base conversion program(part 2)
> I want to convert the base10 number to baseM( first in 2-9)
> eg. 5(10)------>101(2)
> eg. 10(10)-----> 22(4)
> ******the above program can not run and there are some mistake that i
> can't find out
> please help me to correct them
>
> ******Since i need to hand in it tomorrow , please help me as soon as
> possible
> thank you for your help


We will not provide you with a complete solution, and there is so much
wrong with the code you've put up here that there's frankly little
chance of getting it into any useful state.

If you can't do the task set, you need to go back and talk to your
instructor.

 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      03-22-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <math.h>
> main()


int main (void)

> {
> float num;
> int i, temp, remainder, baseM, j;
> printf("Enter a number:");


fflush(stdout);

> scanf("%f",&num);
> printf("Enter the base that you want:");
> scanf("%d",&j);
> if (temp > baseM){
> temp = num;
> remainder = temp % baseM;
> temp = temp / baseM;
> }
> for ( i=num; i>=0; i++)


this won't terminate if i starts off > 0

> remainder[i] = remainder;
> printf("%s",remainder[i]);
> system("PAUSE");


return 0;

> }
>
> ****** this is a base conversion program(part 2)
> I want to convert the base10 number to baseM( first in 2-9)
> eg. 5(10)------>101(2)
> eg. 10(10)-----> 22(4)
> ******the above program can not run and there are some mistake that i


what does "can not run" mean?


> can't find out
> please help me to correct them
>
> ******Since i need to hand in it tomorrow


perhaps you should have started sooner?

> , please help me as soon as
> possible
> thank you for your help



--
Nick Keighley

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New Releases: Mr. & Mrs. Smith, Complete Buffy & Enterprise: Updated complete R1 DVD DB & info lists Doug MacLean DVD Video 0 08-09-2005 05:07 AM
Re: Request: A+ Complete 3rd edition (PDF) [1/1] - A+ Complete 3rd edition.txt (1/1) Spammy Sammy A+ Certification 0 03-04-2005 12:55 PM
New Releases: Criterion additions, WB Gangsters & Coupling: Complete: Updated complete downloadable R1 DVD DB& info lists Doug MacLean DVD Video 4 11-07-2004 05:20 PM
Mr. Bean Complete Bean NOT complete!! Waterperson77 DVD Video 5 12-10-2003 05:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments