473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

please help me to correct/ build/ complete the program

#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
3 1255
<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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: hubert_s | last post by:
I have DB2 8.1 FP7, when I try to build a Java stored procedure it fails during a call to DB2_REPLACE_JAR. Even the build folder "bld1096553970703" is not there - it has a different name, ...
4
by: Pete H | last post by:
I would like to have my new C++ projects start out with two configurations, UnicodeDebug and UnicodeRelease, instead of the standard Debug and Release configurations that Visual Studio always...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
3
by: michael.lang | last post by:
I am using PostBuild events in a C# project to run some tasks, but only when in release configuration mode. The build events run perfectly as expected when run. The problem comes when I save the...
2
by: Bsnpr8 | last post by:
I need help guys, i have to many stuff to do, because i am in my last 2 weeks of the university, my last assignment is to do a spell checker in C++, i have an idea but nothing is coming out. I really...
10
by: =?Utf-8?B?am9uaWdy?= | last post by:
New to VB.NET, designing my first form with an MS manual at my side, placing objects and writing code. For good reason I just: SAVED All (!!) deleted all objects leaving only a grey form,...
0
by: Yannick | last post by:
Hi, I'm Julien from France, We have recently install a new Web Server for my company The server is composed : - Linux RedHat RHEL4 U4 - Httpd-2.0.52-27.ent - Oracle Database 10.2.0.1
0
by: wb5plj | last post by:
Hi I am having a problem passing some sql to the db2cmd via ant. This is very confusing as I am doing this exact thing elseware with no problem (just differant sql, and I have verified the sql is...
5
by: mohammaditraders | last post by:
Question # 1 Write a program which consists of a class named Student, the class should consists of three data members Name, Ob_marks, Total_marks and two member functions...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.