Go to Post When you start new threads, keep in mind that ChiefDelphi has about 14.6 million subforums about nearly everything you can imagine in the world of FIRST. You have to be in the forum you'd like for your thread to appear in when you choose to start a new topic. - Madison [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-04-2008, 12:50
berkanbaba berkanbaba is offline
Registered User
no team
 
Join Date: Apr 2008
Location: turkey
Posts: 6
berkanbaba is infamous around these partsberkanbaba is infamous around these partsberkanbaba is infamous around these parts
Exclamation C Programming Homework Help Needed

i have a question about c programming.can you help for the solution.thank you . i just use C not C++


Question:
Write a C program for a binary notation simulator for positive integer numbers. Your program will ask and get positive integer numbers from user. Program will stop asking new numbers if 0 is input. It will display the binary representation of the input number and the minimum number of digits required to represent that number as given in the sample run.


Sample Run: (Italic and bold letters indicate the user input)
Enter a positive integer: -5
Enter a positive integer: -3
Enter a positive integer: 5
It is 101. At least 3 digits required.
Enter a positive integer: -2
Enter a positive integer: 7
It is 111. At least 3 digits required.
Enter a positive integer: 0
Stop... Bye..
  #2   Spotlight this post!  
Unread 15-04-2008, 13:19
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: C Programming Homework Help Needed

Quote:
Originally Posted by berkanbaba View Post
i have a question about c programming.can you help for the solution.
I'm usually happy to help, but not if it's a homework assignment.

Try asking specific questions about algorithms or representation of data. You will be more likely to get useful answers.
  #3   Spotlight this post!  
Unread 15-04-2008, 13:27
whytheheckme's Avatar
whytheheckme whytheheckme is offline
Registered User
AKA: Jacob Komar
no team
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Providence, RI
Posts: 1,320
whytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond repute
Send a message via ICQ to whytheheckme Send a message via AIM to whytheheckme Send a message via MSN to whytheheckme Send a message via Yahoo to whytheheckme
Re: C Programming Homework Help Needed

Quote:
Originally Posted by Alan Anderson View Post
I'm usually happy to help, but not if it's a homework assignment.

Try asking specific questions about algorithms or representation of data. You will be more likely to get useful answers.
I agree.

Perhaps you could walk us through your strategy to design this project, and we could help you out. Here are some questions to think about:

How are you going to get the binary value of an integer?
How are you going to handle bad input (i.e. negative numbers, and the 0 to escape)?
How are you going to handle having a minimum of three output digits?

Jacob
  #4   Spotlight this post!  
Unread 15-04-2008, 13:54
berkanbaba berkanbaba is offline
Registered User
no team
 
Join Date: Apr 2008
Location: turkey
Posts: 6
berkanbaba is infamous around these partsberkanbaba is infamous around these partsberkanbaba is infamous around these parts
Re: C Programming Homework Help Needed

#include <stdio.h>

void main()
{
int num;
printf("Enter a positive integer: ");
scanf("%d",&num);
while(num!=0)
{
if(num>0)


....


immediate help is needed please !
  #5   Spotlight this post!  
Unread 15-04-2008, 14:19
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,284
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: C Programming Homework Help Needed

An easy way to go from decimal to binary.

Psuedo Code
Quote:
While number>0
push a bit equal to (number mod 2) onto the end of the binary number
divide (number-(number mod 2)) by 2
end while
that should get you started, as a couple of hints, if all you are doing is printing out the number you may not need the array, also c truncates numbers when you do integer math, this simplifies the loop slightly.

See what you can figure out and feel free to ask for help
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
  #6   Spotlight this post!  
Unread 15-04-2008, 14:31
berkanbaba berkanbaba is offline
Registered User
no team
 
Join Date: Apr 2008
Location: turkey
Posts: 6
berkanbaba is infamous around these partsberkanbaba is infamous around these partsberkanbaba is infamous around these parts
Re: C Programming Homework Help Needed

yes you are right.but i'm in the beginning of the programming because i newly started writing some easy programs.i'm only a highschool student and we are not learning c programming lessons now.i write the topic as this was a homework to call your attention..and i have a question waiting for an answer.you are all system engineers or computer software engineers and i think you can give 2 or 3 minutes to my question.i would be very grateful if you can help me on writing the program by steps..
  #7   Spotlight this post!  
Unread 15-04-2008, 14:33
garyk garyk is offline
Programming Mentor: 668, 972, 2643
FRC #0668 (Apes of Wrath)
Team Role: Mentor
 
Join Date: Dec 2006
Rookie Year: 2005
Location: Santa Clara (Silicon Valley) Calif.
Posts: 94
garyk is a jewel in the roughgaryk is a jewel in the roughgaryk is a jewel in the roughgaryk is a jewel in the rough
Re: C Programming Homework Help Needed

Quote:
Originally Posted by berkanbaba View Post
i have a question about c programming.can you help for the solution.thank you . i just use C not C++


Question:
Write a C program for a binary notation simulator for positive integer numbers. Your program will ask and get positive integer numbers from user. Program will stop asking new numbers if 0 is input. It will display the binary representation of the input number and the minimum number of digits required to represent that number as given in the sample run.
Yes, if you post such questions here, you're going to get mentored - such is the Way of First :-)

A quick websearch found a the same kind of tutorial most of us would have written: http://www.swarthmore.edu/NatSci/ech...th/NumSys.html

Stop reading (at least for these purposes) at "Hexadecimal, Octal, Bits, Bytes and Words.", and skip mention of negative numbers and fractions. The article gives a good introduction, and even has a couple of self-test questions.

I encourage you to not go to Wikipedia, their article is a good reference but a poor tutorial.
__________________

Silicon Valley Regional 2005, 2006 972
Silicon Valley Regional 2007 668 Xerox Creativity Award
Championship Event 2007 668
Portland Regional 2008 668
Silicon Valley Regional 2008 668, 972
Beta Test Team 2008 668 (with 100 & 254)
Silicon Valley Regional 2009 668 Regional Chairman's Award; 2643
Sacramento Regional 2009 668 Winning Alliance (thanks, 1717 & 2473!), 2010 Winning Alliance 3256
CalGames 2006, 2007, 2008, 2009, 2010, 2011 Field Tech
NorCal FTC Regional 2008, 2009 Inspector
Championship Event 2009
San Diego, Silicon Valley Regionals; Champ. Event 2010 668, 2643, 3256
Silicon Valley, Madera Regional 2012 2643
WRRF Programming Instructor 2006-2016
Regional Woodie Flowers Award 2014 2643 Utah Regional

  #8   Spotlight this post!  
Unread 15-04-2008, 14:49
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: C Programming Homework Help Needed

Quote:
Originally Posted by berkanbaba View Post
i write the topic as this was a homework to call your attention..and i have a question waiting for an answer.
You should not expect others to do your homework for you.
Quote:
you are all system engineers or computer software engineers
No, we're all part of a program called FIRST. Some of us are engineers, and a few of us are professional computer programmers, but the majority of the people reading your post are high school students.
Quote:
and i think you can give 2 or 3 minutes to my question.i would be very grateful if you can help me on writing the program by steps..
It would be easy to spend a few minutes to write a program to satisfy your assignment. That's not the way it works around here, though.

JamesBrown and garyk have given good advice. Again, if you have specific questions about how to do something, you'll find us ready to answer them.
  #9   Spotlight this post!  
Unread 15-04-2008, 14:52
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: C Programming Homework Help Needed

I think you're missing the point of those that posted above. Yes, there are people on these boards that could write your program for you in less time than it would take to state the problem, but how is that going to help you as a student? When it comes to learning how to program, I guarantee you that the best way to learn is to struggle through the homework and ask appropriate questions to aid your learning.

The main problem that I see with your approach is that you're looking at the problem as a whole and trying to solve it as a whole. If you were given a large algebra problem like 2x + (x - 4) / x = 3y - x + 2 and were told to solve for y when x was 4, how would you do it? Probably in steps right?

You should treat your assignment the same way. So what steps/things do you have to do to complete your assignment?
1. Get an input from the user
2. Determine if the number can be processed
3. If the number can be processed, process it
3a Convert the number to binary
3b Print out the result
4. If the number is 0, print then exit your program

The best advice that I can give when you're given an overwhelming problem is to write a little bit, test, fix what's broken, retest, and repeat until the whole problem is done.

Try writing a program that first does step 1. Then add on step 2 (you can use prints to let you know whether the number will be processed or not). Then add step 4 (skipping 3 for now). Then add steps 3 and 3b. Notice that I left the hard stuff (binary conversion) until the end. Once your program has the framework to do everything but the binary conversion, add that in.

It really isn't as hard as you think it is. Think through the problem piece by piece and I'm sure that you'll be able to work through it.

If you run into problems, ask specific questions other than "this is my problem, please give me the answer" and I'm sure that you will be more likely to get the appropriate help.
  #10   Spotlight this post!  
Unread 15-04-2008, 15:12
berkanbaba berkanbaba is offline
Registered User
no team
 
Join Date: Apr 2008
Location: turkey
Posts: 6
berkanbaba is infamous around these partsberkanbaba is infamous around these partsberkanbaba is infamous around these parts
Re: C Programming Homework Help Needed

i don't need to know your advertisements or whatever you are working in just ask a question and reading some blank messages..

so thank you dave for your kind message.i can write the program but one step is required.

you said

3a Convert the number to binary

in your message.and i don't know how to find the binary of the number on a program.i can do the others bur the main problem is this part because i don't know it.i want to say it again this is not a homework or assignment because in highschool there is no lesson about programming.i will see c programming on the college next year and i started learning it 3 months ago.i'm new at this and i'm saying that i need help but some of you writing me messages with no knowledge in them..

one step is needed dave waiting your message..thank you..
  #11   Spotlight this post!  
Unread 15-04-2008, 15:26
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: C Programming Homework Help Needed

Berkanbaba,

Often the best way to answer a question is to first ask a few in return. Before anyone can help you, I think we need to know:



Do you know what binary numbers are?



Here's a quick warning: Your profile says you're from Turkey, which in itself is not a problem at all. Understand that in North America we often have different perspectives on what "learning" is. I say this having had family and friends educated overseas, where "learning" centres around memorizing and repetition. Not so much emphasis is put on understanding.

You will not find anyone here who will write your program for you.

You will find dozens willing to teach you and direct you to source where you will 100% learn and understand how to write your own program.

That's approximately infinitely more valuable in my opinion.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
  #12   Spotlight this post!  
Unread 15-04-2008, 15:41
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,284
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: C Programming Homework Help Needed

Quote:
Originally Posted by berkanbaba View Post
i don't know how to find the binary of the number on a program.
I outlined an algorithm to find binary numbers in my post above, do you understand what i said to do? If you don't what do you need more advice on. If you understood what i said then where are you getting stuck.

Honestly from what you have said the only thing that would seem to satisfy what you are looking for would be for us to write the program for you which quite frankly i am not going to do. All we ask is that you ask more specific questions.
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
  #13   Spotlight this post!  
Unread 15-04-2008, 15:47
berkanbaba berkanbaba is offline
Registered User
no team
 
Join Date: Apr 2008
Location: turkey
Posts: 6
berkanbaba is infamous around these partsberkanbaba is infamous around these partsberkanbaba is infamous around these parts
Re: C Programming Homework Help Needed

my genius friend slimbo jones

yes i know the binary numbers but don't know how to write on C.

Do you know how to write binary numbers in a C program ?

i don't know where are you from but think that toronto is not your real town.i don't need your education knowledge or your learning perspective.and i think in your hometown you don't know anythink about helping..but as an engineer you should know this ethic i think.

thank you for your genious decisions and opinions but you answered my question with another question and that is your answer i think lol
  #14   Spotlight this post!  
Unread 15-04-2008, 16:17
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: C Programming Homework Help Needed

My genius friend Berkanbaba,

Toronto is indeed my hometown, and I have been consistently recognized as one of the best engineers in my profession, one of the best business people in my industry, one of the best mentors in FIRST, and one of the best teachers in both computer science and mathematics in my area.

I challenge my students, colleagues, and peers at every opportunity, and will now challenge you in the same way.

I actually don't believe you know binary numbers.

Prove me wrong.

Take the number 188, and show us all, step by step, how you would convert it into binary representation.

Whether you realize it or not, if you can successfully do this, you'll end up getting the help you so desperately need with your assignment. But only after you do this can the community here help you code each of your steps into C.

...urgently waiting on your reply berkanbaba...
__________________
In life, what you give, you keep. What you fail to give, you lose forever...

Last edited by Mr. Lim : 15-04-2008 at 16:51.
  #15   Spotlight this post!  
Unread 15-04-2008, 17:11
berkanbaba berkanbaba is offline
Registered User
no team
 
Join Date: Apr 2008
Location: turkey
Posts: 6
berkanbaba is infamous around these partsberkanbaba is infamous around these partsberkanbaba is infamous around these parts
Re: C Programming Homework Help Needed

@ genius slimbo jones

you look like not a toronto people korean or chinese or like that..you are the king congratulations or you think that you are the best,nice for you.you said you have challanged with your students what a genius man you are challenging with students huh!

take your number or whatever you want..

@dave

thanks again man you really helped me to make the program.


#include<stdio.h>
int main(void)
{
int sayi,bolum,kalan,sonuc=0,counter=0,p=1,i;
for(i=0;i>-1;i++)
{
do
{ printf("Enter a positive integer:");
scanf("%d",&sayi);}
while(sayi<0);
if(sayi==0)
{
printf("Stop... Bye..");
break;}
else
{do
{bolum=sayi/2;
kalan=sayi-(bolum*2);
sayi=bolum;
p=1;
for(i=0;i<counter;i++)
{p=p*10;
}sonuc=sonuc+(kalan*p);
counter++;}
while(bolum!=0);
printf("It is %d. At least %d digits required.\n",sonuc,counter);}
sonuc=0;
counter=0;}
getchar();
getchar();
return 0;
}


@ indiana jones

take your number and write it.or just run it in your ..head.

take your community and go higher the flying man..

best wishes super genius indiana jones.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C Programming Homework Help Needed Pat McCarthy Programming 53 27-09-2008 22:15
programming help needed krunal Programming 3 29-01-2007 00:18
HELP-URGENT PROGRAMMING HELP NEEDED Rohith Surampudi Lego Mindstorm Discussion 1 24-03-2006 23:05
URgent Programming Help needed rcubes85 Programming 4 15-02-2005 23:21


All times are GMT -5. The time now is 01:47.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi