Thread: C programming user that ask to continue

  1. #1
    Registered User
    Join Date
    Oct 2015
    Location
    Dipolog City,Philippines
    Posts
    2

    C programming user that ask to continue

    hello everyone I'm a first year student of BS IT, my program is input your birth month and birth date that determine your zodiac sign. Please help this code, my teacher said this code is correct but he said put a code that the user ask "would you like continue? [Y/N]: ? please help what is the code I use. I'm using c programming language in TC

    Sample Output:
    Enter your birth month and birth date as a number: 08 16

    Your zodiac sign is LEO

    Code:
    #include<stdio.h>#include<conio.h>
    main()
    {
    int month,date;
    clrscr();
    	printf("\n Enter your birth month and birth date as a number:");
    	scanf("%d%d",&month,&date);
    		if ((month == 1 && date >= 20)||(month == 2 && date <=18))
    
    
    		printf("\n \n Your zodiac sign is AQUARIUS");
    
    
    		else if (( month == 2 && date >= 19)||( month == 3 && date <= 20))
    
    
    		printf("\n \n Your zodiac sign is PISCES"); 
    
    
    		else if (( month == 3 && date >= 21)||( month == 4 && date <= 19))
    
    
    		printf("\n \n Your zodiac sign is ARIES");
    
    
    		else if (( month == 4 && date >= 20)||( month == 5 && date <= 20))
    
    
    		printf("\n \n Your zodiac sign is TAURUS");
    
    
    		else if (( month == 5 && date >= 21 )||( month == 6 && date <= 20 ))
    
    
    		printf("\n \n Your zodiac sign is GEMINI");
    
    
    		else if (( month == 6 && date >= 21 )||( month == 7 && date <= 22 ))
    
    
    		printf("\n \n Your zodiac sign is CANCER");
    
    
    		else if (( month == 7 && date <= 23 )||( month == 8 && date <= 22))
    
    
    		printf("\n \n Your zodiac sign is LEO");
    
    
    		else if (( month == 8 && date >= 23 )||( month == 9 && date <= 22 ))
    
    
    		printf("\n \n Your zodiac sign is VIRGO");
    
    
    		else if (( month == 9 && date >= 23 )||( month == 10 && date <= 22))
    
    
    		printf("\n \n Your zodiac sign is LIBRA");
    
    
    		else if (( month == 10 && date >= 23 )||( month == 11 && date <= 21))
    
    
    		printf("\n \n Your zodiac sign is SCORPIO");
    
    
    		else if (( month == 11 && date >= 22 )||( month == 12 && date <= 21))
    
    
    		printf("\n \n Your zodiac sign is SAGUITTARIUS");
    
    
    		else if (( month == 12 && date >= 22 )||( month == 1 && date <= 19 ))
    
    
    		printf("\n \n Your zodiac sign is CAPRICORN");
    	
    		else
    
    
    		printf("\n INVALID INPUT");
    
    
    	getch();
    	return(0);
    	}

  2. #2
    spaghetticode
    Guest
    You want to read up on while- and do..while-loops. If your class doesn't use a textbook, you could peek into the tutorial on this very website.

  3. #3
    Registered User
    Join Date
    Oct 2015
    Location
    Dipolog City,Philippines
    Posts
    2

    c programming

    Quote Originally Posted by spaghetticode View Post
    You want to read up on while- and do..while-loops. If your class doesn't use a textbook, you could peek into the tutorial on this very website.
    I make this code but I don't know what is the error, still studying the while and do while loops.
    Code:
    #include<stdio.h>#include<conio.h>
    main()
    {
    int month,date,stop = 0;
    do
    {
    clrscr();
    	printf("\n Enter your birth month and birth date as a number:");
    	scanf("%d%d",&month,&date);
    	i++;
    	printf("\n\nMore data? -1 to stop, others to continue:");
    	scanf("%d",&stop); 
    	} while(stop != -1);
    	if ((month == 1 && date >= 20)||(month == 2 && date <=18))
    		{
    		printf("\n \n Your zodiac sign is AQUARIUS");
    		}
    		else if (( month == 2 && date >= 19)||( month == 3 && date <= 20))
    		{
    		printf("\n \n Your zodiac sign is PISCES"); 
    		}
    		else if (( month == 3 && date >= 21)||( month == 4 && date <= 19))
    		{
    		printf("\n \n Your zodiac sign is ARIES");
    		}
    		else if (( month == 4 && date >= 20)||( month == 5 && date <= 20))
    		{
    		printf("\n \n Your zodiac sign is TAURUS");
    		}
    		else if (( month == 5 && date >= 21 )||( month == 6 && date <= 20 ))
    		{
    		printf("\n \n Your zodiac sign is GEMINI");
    		}
    		else if (( month == 6 && date >= 21 )||( month == 7 && date <= 22 ))
    		{
    		printf("\n \n Your zodiac sign is CANCER");
    		}
    		else if (( month == 7 && date <= 23 )||( month == 8 && date <= 22))
    		{
    		printf("\n \n Your zodiac sign is LEO");
    		}
    		else if (( month == 8 && date >= 23 )||( month == 9 && date <= 22 ))
    		{
    		printf("\n \n Your zodiac sign is VIRGO");
    		}
    		else if (( month == 9 && date >= 23 )||( month == 10 && date <= 22))
    		{
    		printf("\n \n Your zodiac sign is LIBRA");
    		}
    		else if (( month == 10 && date >= 23 )||( month == 11 && date <= 21))
    		{
    		printf("\n \n Your zodiac sign is SCORPIO");
    		}
    		else if (( month == 11 && date >= 22 )||( month == 12 && date <= 21))
    		{
    		printf("\n \n Your zodiac sign is SAGUITTARIUS");
    		}
    		else if (( month == 12 && date >= 22 )||( month == 1 && date <= 19 ))
    		{
    		printf("\n \n Your zodiac sign is CAPRICORN");
    		}
    		else
    		{
    		printf("\n INVALID INPUT");
    
    
    		getch();
    		return(0);
    		}

  4. #4
    spaghetticode
    Guest
    Code:
    do {    // Begin looping
        // whatever needs to be repeated goes here
        // repeat this as long as...
    } while (stop != -1);    // ...this is true
    Try to say in your own words what actions (step by step) need to be repeated to fulfil the assignment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to programming.. question about "continue;"
    By sdbuilt in forum C Programming
    Replies: 2
    Last Post: 09-06-2012, 07:34 PM
  2. How to continue if no user input
    By Charlie Lesoine in forum C Programming
    Replies: 5
    Last Post: 10-03-2011, 07:34 PM
  3. User Interface Programming
    By Imanuel in forum C++ Programming
    Replies: 10
    Last Post: 09-11-2011, 04:06 AM
  4. Replies: 1
    Last Post: 05-24-2010, 06:42 PM
  5. function to prompt user to continue entering data or not
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 05-05-2002, 06:38 PM

Tags for this Thread