Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

4 code menu driven software system needed! 3

Status
Not open for further replies.

nkabirwa

Programmer
May 6, 2002
4
US
Am a beginner in Computer science and information technology, i've failed to figure out a 4 code menu driven software system that accepts an input in decimal& converts it to both hexadecimal and binary equivalent, and a programme that outputs a factorial of any number that is input by a user. I would also appreciate simple C notes for beginners.
 
Dear russ,
This is the code am having problems with:
#include,stdio.h.
#include,conio.h.
main()
{
int y;
printf("Enter 1 to convert to binary:\n");
printf("Enter 2 to convert to hexadecimal:\n");
printf("Enter 3 to exit");
printf("Enter your choice:);
scanf("%d",&y);

switch(y)
Case 1: {
int t,x=0,n,a[10],i=0;
printf("Enter a decimal number:");
scanf("%d",&n);
while(n>1){
for(x=1;x<=32;x++){
t=n%2;
x=n/2;
a=t;
printf(&quot;%d&quot;,t);
for(i=0;i<=9;i--){
n=x;
break;
}
}
}
}
Case 2: {
int t,n,x=0,[10],i=0;
printf(&quot;Enter a decimal number&quot;);
scanf(&quot;%d&quot;,&n);
While(n>=16){
for( ;x<=200;x++){
t=n%16;
x=n/16;
t=p;
if(t<=9){
printf(&quot;%d&quot;,p);
else if(t==10)
printf(&quot;A&quot;);
else if(t==11) and so on and so forth
}
}
break;
Case 3: exit(0)
break;
}
}
The errors that i found when i tried to run it were it cannot open include<stdio.h> and include<conio.h>.
Thank u very much all of u who responded i appreciate it. God Bless u!
 
nkabirwa,
instead of the following:

#include,stdio.h.
#include,conio.h.

use:
#include <stdio.h>
#include <conio.h>

your Case's should be
case '1':
code goes here
break;
case '2':
more code....

also, instead of declaring int t,n,x=0,a[10],i=0; in each case, declare them outside, it saves time and chances of errors. it is also good practice to delcare as follows:
int t,n;
int x=0;
int i=0;
int a[10];

this, int t,n,x=0,a[10],i=0; seems confusing...

-a5k
 
Hello -a5k,
Thanks alot for the corrections, but The libraries:
#include<stdio.h> and #include<conio.h> were wrongly typed in my previous text, so i made adjustments, and tried to run it again, but the errors remained it can't open them, i mean #include<stdio.h> and #include<conio.h> what could be the problem? Or where might have gone wrong? Please advice.

I would once again like to thank u from the bottom of my heart, and let u know that this is so helpful to me, and would appreciate anything else that would be of help to me as a beginner. May the good Lord bless u Big!

Nkabirwa.
 
What platform are you programming in? I know that in some Unix flavors, conio.h will not be found. That is, it's not a part of the standard library. However stdio.h should work just about anywhere.

-a5k
 
Hi nkabirwa,

Check how you're compiler environment is set up: is it looking for your include files in the right place (ie when you put the file in <>'s then it looks in it's standard includes directory, so check your documentation for how to make sure the standard directory is set right).

Afraid I can't tell you how to do it if I don't know what environment you're using. (And even then, I don't know very many, but whatever it is I'm sure someone else here will!)

Take it easy,
Goodyear
 
Hi Guys,
Thanks alot for responding to my thread, and am so sorry that i took long to reply.
The environment am using is Turbo C 2.0, but still it wont open those libraries.
what Goodyear suggeste is right, but i don't know how to rectify this problem, please teach me how to adjust it, so i can run this program.

I would love to learn more about adjusting the system to standard includes directory.

Thanks alot once again
nkabirwa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top