Thread: illegal break?!?!?

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    12

    illegal break?!?!?

    i am working on homework for my programming class which uses C. i have to make a program that calculates some simple geometry. the user chooses which shape to make calculations on. i am using a switch statement but when i try to break, it comes up as illlegal break when i compile. can anyone help? this is just part of the program

    Code:
    switch(shape)
    	case 1:
    		printf("Enter the radius of a circle(9999 to quit):\n");
    		scanf("%lf", &radius);
    
    		while(radius != 9999){
    			while(radius < 0){
    				printf("Invalid input!\n");
    				printf("Enter the radius of a circle(9999 to quit):\n");
    				scanf("%lf", &radius);
    				}
    			area = radius * radius * PI;
    			circumference = 2 * radius * PI;
    			printf("The area of the circle is %.2lf\nThe circumference of the circle is %.2lf\n", area, circumference);
    
    			printf("Enter the radius of a circle(9999 to quit):\n");
    			scanf("%lf", &radius);
    			}
    		break;
    
    	case 2:

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Is the missing opening brace after switch(shape) just a typo when you posted the code, or is it a typo in your code itself?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    12
    lol something so simple
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Number to Word (Billions)
    By myphilosofi in forum C Programming
    Replies: 34
    Last Post: 02-04-2009, 02:09 AM
  3. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  4. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 10:18 PM

Tags for this Thread