473,672 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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",rem ainder[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 1269
<jy****@gmail.c omwrote:

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.co m 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",rem ainder[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.co m 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",rem ainder[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
3598
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, regards, Hubert DB2ADMIN.PROCEDURE2 - Build started. DROP SPECIFIC PROCEDURE DB2ADMIN.SQL030805133228210 DB2ADMIN.PROCEDURE2 - Drop stored procedure completed.
4
2540
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 creates. Is there a way to configure Visual Studio to do this Thanks in advance - Pete H
1
9626
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
3
11287
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 project, close VS, and reopen VS and the project. When I build again, i get a post-build event error. So I open the event to look at it. Guess what, it is not the post-build event i saved. Instead all the carriage returns are replaced with...
2
2132
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 need help, could someone do, anything to help me i don't have much time, here are the instructions: Instructions: In this project, you are asked to develop your own spell-checker utility. We make suggestions to help get you started. You should...
10
1331
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, ran my program to see the result, then UNDO to get my objects back.
0
4775
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
4011
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 valid) but in this one I am having problems. Any time I run this I get the folowing message from the db2 clp window that opens up. SQL0104N An unexpected token "SET" was found following "<identifier>". Expected tokens may include: "NEW". ...
5
2192
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 Cal_percentage() which calculate the percentage of the student by the formula (Ob_marks * 100 )/Total_marks and Display() which show all information of the student. The class should also contain the default constructor which initializes all the data member of...
0
8506
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8948
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8649
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8701
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7482
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5725
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4251
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.