Thread: what could be wrong with this programming?

  1. #1
    Registered User
    Join Date
    Jun 2007

    Question what could be wrong with this programming?

    # include <std.h>
    int main ()
             int x;
             for(x=0; x<10; x++){
            printf(" %d/n" , x)
           return 0;
    was trying out the loope for and compiled this simple programme bt i dont understand what the output means. pls, could someone compile it and let me know what the problem could be?

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    1. Learn how to indent
    2. Each number you see (when it's compiled) will be the 0-based iteration number, ie, it starts at 0, then runs again 1, then 2 and so on... really look at a C tutorial regarding for loops...

    And what problem?
    Last edited by zacs7; 06-11-2007 at 06:43 AM.

  3. #3
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    #include <stdio.h>
    To be or not to be == true

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > printf(" &#37;d/n" , x)
    If you actually have output, then it would be from a different program, not this one.
    This line is missing a ; and the / should be \

    Try to post code which you actually tried, and the actual output you got.

    Posting paraphrased code and "it doesn't work" won't get you much quality information.
    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.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    look at a C tutorial regarding for loops...
    Here's one.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Join Date
    Jun 2007
    Las Vegas

    Even if the others said it before, I am saying it all in one

    Fisrst of all, If u do not want to indent, because C does not require it( I reccomend u to learn it), u can just put all of te code on no indent!

    Second, From what I see, You know nothing about C, no offence! I do not know much myself!

    And third, as a good practice, write your own code, don't just copy!

    As Keringham and Ritchie said, and many others, "You can only learn to program in a language, just by writing programs in it"

    Writing code is a very good practice

    Sry for any offence and I hope you will take these people's advice and learn C!
    It is a fascinating language!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of
    Replies: 1
    Last Post: 11-03-2003, 09:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 12:40 PM
  4. God
    By datainjector in forum A Brief History of
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 01:04 PM