Thread: Help with while's and scanf's...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    12

    Help with while's and scanf's...

    hey
    im new here and i have an exam tomorrow so i need to learn how to do this!!!

    the question is to write a program that prompts the user to enter a value, with a message then being displayed that is dependent on teh value entered....
    the message should be 1 = happy first birthday
    17 = you can learn how to drive
    30 = still young
    40 = getting older

    so far i got:

    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include <CLIB.H>
    
     main()
     { 
       int c;
       printf("Enter value: \n");
       
       while (1)
       scanf("%d",&c);
       
       switch(c)
       {
         case 1: printf("hello you");
       break;
       case 17: printf("you can learn to drive");
       break;
       case 30: printf("still young");
       break;
       case 40: printf("getting older");
       break;
       }
     
       return 0;
       
    
     }
    what am i doing wrong?
    thanks
    Last edited by m600; 01-19-2010 at 02:15 PM.

Popular pages Recent additions subscribe to a feed