|
From: sushmita u. <sus...@ya...> - 2001-01-17 05:36:04
|
it seems that u r familiar with both c and c++ the switch statement is used in place of multiple if/else statements --- James Gordon <Jam...@Cl...> wrote: > 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: > "); > === message truncated === __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ |