what could be wrong with this programming?

This is a discussion on what could be wrong with this programming? within the C Programming forums, part of the General Programming Boards category; Code: # include <std.h> int main () { int x; for(x=0; x<10; x++){ printf(" %d/n" , x) } getchar(); return ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Location
    finland
    Posts
    2

    Question what could be wrong with this programming?

    Code:
    # include <std.h>
    
    int main ()
    
    {
    
             int x;
          
             for(x=0; x<10; x++){
    
            printf(" %d/n" , x)
           
             }
          
           getchar();
    
           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
    Location
    Australia
    Posts
    3,459
    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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,471
    #include <stdio.h>
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,439
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    look at a C tutorial regarding for loops...
    Here's one. http://www.cprogramming.com/tutorial/c/lesson3.html
    dwk

    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: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    #C-help
    Join Date
    Jun 2007
    Location
    Las Vegas
    Posts
    53

    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 Cprogramming.com
    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 Cprogramming.com
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21