illegal break?!?!?

This is a discussion on illegal break?!?!? within the C Programming forums, part of the General Programming Boards category; i am working on homework for my programming class which uses C. i have to make a program that calculates ...

  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
    20,968
    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?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 01:09 AM
  3. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 04:42 PM
  4. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 09:18 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21