By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 847 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

please help me to correct/ build/ complete the program

P: n/a
#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

Mar 21 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
<jy****@gmail.comwrote:

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>
Mar 21 '07 #2

P: n/a
On 21 Mar, 13:23, jyc...@gmail.com 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.

Mar 21 '07 #3

P: n/a
jy****@gmail.com 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

Mar 22 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.