The goto statement


    #include <iostream.h>
    #include<conio.h>
    #include<stdio.h>
    void main()
    {
        int num ;
        char ans ;
            again : clrscr () ;
        printf ("Enter a number :\n") ;
        cin>>num;
        if (num % 2 == 0)
            cout<<"The number "<<num<<" is EVEN\n";
        else
            cout<<"The number "<<num<<" is ODD\n";

        cout<<"Do you want to continue (Y or N) ? : " ;
        cin>>ans;

        if ((ans == 'y') || (ans == 'Y'))
            goto again ;
       else
            cout<<"Thank You !!\n";
    }

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|