Thread: beginner ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    5

    Question beginner ?

    when i type anything but a number the program starts a endless loop. what code can i write into the program to stop this ,and what causes the loop.

    Code:
    #include <stdio.h>
    
    int main()
    {
    
       int x;
    
       printf("enter a numbr 1 thru 10\n");
       scanf("%d",&x);
       
       if (x<1 || x>10)
       main();
    
       else 
       printf("\nyou typed %d",x);
    
       return(0);
    }
    Last edited by braincrash; 02-18-2003 at 12:14 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 11:48 AM
  2. What are some good beginner programs I shouold make?
    By oobootsy1 in forum C# Programming
    Replies: 6
    Last Post: 08-09-2005, 02:02 PM
  3. Best Free Beginner Online Books/Tutorials?
    By Zeusbwr in forum C++ Programming
    Replies: 2
    Last Post: 10-12-2004, 05:52 PM
  4. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM