|
From: James G. <Jam...@Cl...> - 2001-01-16 13:57:37
|
Either but a book on C or C++, if you can. Or search www.google.com. Or try here http://msdn.microsoft.com/library/devprods/vs6/visualc/vclang/_clang_the_c_s witch_statement.htm I know is MS but it's all the same. It was just the first site I can across using goggle the described the C switch statement. Regards, James. -----Original Message----- From: Frazell Thomas [mailto:fr...@fl...] Sent: Tuesday, January 16, 2001 1:50 PM To: dev...@li... Subject: RE: [Dev-C++] (no subject) I don't know about switch statements can u refer me to some online documentation or give me a brief tutorial thanks -----Original Message----- From: dev...@li... [mailto:dev...@li...]On Behalf Of James Gordon Sent: Tuesday, January 16, 2001 8:35 AM To: 'dev...@li...' Subject: RE: [Dev-C++] (no subject) You have if(type = 'Q'); <--- remove the ; as you have an empty control statement. Your missing a return before the closing } in main. Basically if your program doesn't run into any of the if tests then it falls out of the bottom without returning a value. (add return 0; before the last }) A suggestion would be to replace the if's with switch statements. i.e. switch(type) { case 'Q': ... break; case 'C': ... break; } Regards, James. -----Original Message----- From: Frazell Thomas [mailto:fr...@fl...] Sent: Tuesday, January 16, 2001 1:09 PM To: Dev...@Li... Subject: [Dev-C++] (no subject) I'm trying to add another feature to my primitive program :O) I was trying to add a regular calculator allowing a choice from the quadratic equation calculator and from a regular arithmetic calculator I keep getting two errors which I marked in the code below I'm still a beginner so I as if what I'm trying to do even possible if not can I have a program open either one (each in its own executable) if so how? Thanks Error summary 1. Parse error before 'else' line 69 2. Parse error before '}' line 100 The errors are marked with a '< ----------------' in red if you can read html mail ---------------------------------------------------------------------------S ORCE CODE (Errors are marked below in color which may require HTML email to see)------------------------------------------------------------------------ ------------------------------------ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <windows.h> char type; int a,b,c; float sroot, divide, answer_1, answer_2; double determinent; float calc1,calc2; int calc3; char typec; int main() { //Asks user which caculator does he/she want to start printf("What type of calcultor do you need? Please enter 'Q' for Quadratric Eqations \nand 'C' for a stadered calculator: "); scanf("%c" ,&type); // Determines which calculator user selected and uses the one chosen if(type=='Q'); { printf("This program is designed to do quadratic equations only.\n"); printf("You are free to use this software as stated under the GNU\n"); printf("Public License (Avalible at GNU.org).\n\n"); printf("Version: Beta 1.4 1/3/2001 6:00AM EST.\n"); printf("Programmer: Frazell Thomas\n"); printf("Programmer: Hoo Hong\n"); printf("Please visit http://www.frazellthomas.com\n\n"); // Input From User printf("Please enter the number used to represent varible A: "); scanf("%d", &a); // if statement to prevent the divide error if the var. a is zero if (a == 0) { printf("\nSorry you entered 0 this will result in an error try again."); printf("\nPlease enter the number used to represent varible A: "); printf("\nEnter 0 again to quit: "); scanf("%d", &a); if (a==0) { return 0; } } printf("\nPlease enter the number used to represent varible B: "); scanf("%d", &b); printf("\nPlease enter the number used to represent varible C: "); scanf("%d", &c); determinent = (pow(b,2) - 4*a*c); if (determinent < 0) { printf("\nSorry, The equation you entered returned no real result.\n"); printf("Please re-run the program entering an equation that will give you a real result."); system("Pause"); return 0; } sroot = sqrt(determinent); divide = 2 * a; answer_1 = (-b - sroot) / divide; answer_2 = (-b + sroot) / divide; // Prints the answer printf("\nThe Answer Is %.4f and %.4f\n ", answer_1, answer_2); system("Pause"); return 0; } else if(type=='C') < -----------------Parse error before 'else' { printf("\nPlease input the first integer: "); scanf("%f" ,&calc1); printf("\nEnter the sign ('+','-','*','/'): "); scanf("%c" ,&typec); printf("\nPlease input the second integer: "); scanf("%f" ,&calc2); if(typec=='+') { calc3=calc1+calc2; } if(typec=='-') { calc3=calc1-calc2; } if(typec=='*') { calc3=calc1*calc2; } if(typec=='/') { calc3=calc1/calc2; } //Returns Answer From Standerd Calculator To User printf("\n%f %c %f = %f ",calc1,typec,calc2,calc3); system("PAUSE"); return 0; } } < ------------------Parse error before '}' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This electronic message and any attachment is intended to be read by the named addressee(s) only. Any other recipient should be aware that its contents may be legally privileged and/or confidential and that its use, disclosure, copying or distribution may be unlawful. Unless you are a named addressee, please delete this message Whilst C. & J. Clark International Limited has taken steps to prevent the transmission of computer viruses with electronic mail, responsibility for screening incoming messages and the risk of such transmission and its consequences lies with the recipient. C. & J. Clark International Limited Registered in England and Wales Company No. 141015 Registered Office: 40 High Street, Street, Somerset BA16 0YA Telephone: +44 (0) 1458 443131 Fax: +44 (0) 1458 447547 _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/lists/listinfo/dev-cpp-users _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/lists/listinfo/dev-cpp-users * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This electronic message and any attachment is intended to be read by the named addressee(s) only. Any other recipient should be aware that its contents may be legally privileged and/or confidential and that its use, disclosure, copying or distribution may be unlawful. Unless you are a named addressee, please delete this message Whilst C. & J. Clark International Limited has taken steps to prevent the transmission of computer viruses with electronic mail, responsibility for screening incoming messages and the risk of such transmission and its consequences lies with the recipient. C. & J. Clark International Limited Registered in England and Wales Company No. 141015 Registered Office: 40 High Street, Street, Somerset BA16 0YA Telephone: +44 (0) 1458 443131 Fax: +44 (0) 1458 447547 |