Thread: IF statement

  1. #16
    Registered User
    Join Date
    Nov 2004
    Posts
    10
    the reason for this is: we havent covered that in class. its INTRO to computer science, i have no clue what any of that is, just trying to make it work with what ive been given

  2. #17
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    What about my code don't you understand? I can explain how it works if you ask specifics.
    If you understand what you're doing, you're not learning anything.

  3. #18
    Registered User
    Join Date
    Nov 2004
    Posts
    10
    ok, thanks. but thats not the point, I have to do it the way it is. I just need it to work.
    thanks.

  4. #19
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    If you're one of those people who dislike break statements...
    Code:
    for(i = 0;i < 5;++i)
      {
        if(!isdigit(fgetc(fp)))
        {
          valid = 0;
          break;
        }
      }
    Could be...

    Code:
    for(i = 0;i < 5 && valid;++i)
      {
        if(!isdigit(fgetc(fp)))
        {
          valid = 0;
        }
      }
    Quzah.
    Hope is the first step on the road to disappointment.

  5. #20
    Registered User
    Join Date
    Dec 2001
    Posts
    27

    printing 5 digits

    Hi,

    I don't know if this will help but to print 5 digits, even with ints less than 10000, use :

    int num = 0; // can be any number up to 99999
    printf("\nThe number is %05d",num);
    Pappy
    You learn something new everyday.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Usefulness of the "else if" statement
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 05:19 AM
  2. Meaning of this statement?
    By @nthony in forum C Programming
    Replies: 7
    Last Post: 07-16-2006, 02:57 AM
  3. If Else statement problem
    By doofusboy in forum C Programming
    Replies: 2
    Last Post: 11-09-2005, 07:18 AM
  4. if/break statement
    By Apropos in forum C++ Programming
    Replies: 7
    Last Post: 02-22-2005, 02:33 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM