Thread: Urgent need help!!!!!

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    2

    Question Urgent need help!!!!!

    I need help with a program for school. I keep getting a weird volume when I turn the radio on, and frequency wont work. it has to go from am, fm, aux, to mp3. AM frequency (530 kHz-1610kHz, going up by 10kHz). FM frequency (88.1MHz- 180MHz, going up by 100kHz). Volume up and down and a clock.
    Attached Files Attached Files
    Last edited by josh223456; 03-29-2013 at 11:46 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    Topic Titles
    Urgency
    I'll leave you to read the rest of that FAQ
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    The first thing I would suggest is figuring out which language you're supposed to be learning.
    Because at the moment, you have a train-wreck called C/C++.

    Code:
    $ g++ -Wall -c foo.cpp
    foo.cpp: In member function ‘void cRadio::powerbutton()’:
    foo.cpp:54:27: warning: format ‘%d’ expects a matching ‘int’ argument [-Wformat]
    foo.cpp:57:39: warning: too many arguments for format [-Wformat-extra-args]
    foo.cpp:60:39: warning: too many arguments for format [-Wformat-extra-args]
    foo.cpp:63:40: warning: too many arguments for format [-Wformat-extra-args]
    foo.cpp:66:40: warning: too many arguments for format [-Wformat-extra-args]
    foo.cpp: In member function ‘void cRadio::setmode()’:
    foo.cpp:181:39: warning: too many arguments for format [-Wformat-extra-args]
    foo.cpp:184:38: warning: too many arguments for format [-Wformat-extra-args]
    foo.cpp:187:37: warning: too many arguments for format [-Wformat-extra-args]
    foo.cpp:190:38: warning: too many arguments for format [-Wformat-extra-args]
    foo.cpp: At global scope:
    foo.cpp:200:14: error: ‘::main’ must return ‘int’
    The reason you get all sorts of garbage printed is you're abusing printf!

    If you used something like
    cout << "Volume = " << volume << endl;
    there would be a lot less chance of screwing up.

    The other problem I see is that when you switch mode which involves either FM or AM, then you need to reset freq to something appropriate for that band.

    Maybe say
    int lastFMfreq;
    int lastAMfreq;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Mar 2013
    Posts
    2
    could you show me how to make it work cause im very new to programming, and have been stuck on this for hours.

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Given that you used the word "Urgent" in your subject line, I might consider answering your question in a week from next Tuesday. That reflects the actual urgency that is warranted.

    As per one of the links that Salem provided in post #2, flagging your post as urgent is no more than a rude and selfish attempt to gain special attention.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by josh223456 View Post
    could you show me how to make it work cause im very new to programming, and have been stuck on this for hours.
    No. Read the homework policy.
    If you are really struggling with this code, perhaps you a bit on over your head? If so, it might be better to start off with a simpler project.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    printf - C++ Reference

    Not the way I would do it.
    Code:
    		if (power==false){
    		}
    		else
    Shorter and clearer in my view.
    Code:
    		if (power!=false){
    Tim S.
    Last edited by stahta01; 03-30-2013 at 06:29 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  8. #8
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Also here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. urgent please help!!
    By ali_1234 in forum C Programming
    Replies: 1
    Last Post: 03-24-2009, 12:38 PM
  2. Urgent!! Need help
    By nareik9394 in forum C Programming
    Replies: 3
    Last Post: 03-18-2009, 02:11 PM
  3. please please help me its urgent
    By youngashish in forum C++ Programming
    Replies: 8
    Last Post: 12-06-2004, 09:20 AM
  4. pls help me urgent..
    By intruder in forum C Programming
    Replies: 4
    Last Post: 01-13-2003, 04:41 AM
  5. Please help me (urgent)
    By forfor in forum C Programming
    Replies: 3
    Last Post: 12-05-2002, 03:32 PM