FINAL REQUIREMENTReena R. Perez                    http://eglobiotraining.com/
http://eglobiotraining.com/
   In programming, a switch, case, select    or inspect statement is a type of    selection control mechanism that exists...
It is also included in several other types ofprogramming languages. Its purpose is toallow the value of a variable or expr...
   char key; C# In C# programming, every case            printf("Enter an arithmetic operatorn");                     ...
#include<iostream>#include<stdlib.h>using namespace std;int main (){int number_of_units, tuitionfee, paymentforunits;cout<...
   Select Case n                                     Case Is < -5                                       MsgBox("n is le...
   #include<iostream>                                           using namespace std;                                     ...
#include<stdlib.h>#include<iostream>using namespace std;int main(){char gender;cout<<"Enter your Gender.";cin>>gender;if (...
   #include<iostream>                                   using namespace std;   Pascal                                 ...
   #include<iostream>                                    using namespace std;                                   int mai...
#include<stdlib.h>#include<iostream>#include<stdio.h>#include<conio.h>using namespace std;int main(){float total_purchase=...
http://eglobiotraining.com/
http://eglobiotraining.com/
   In programming, very often when you write code, you want    the same block of code to run a number of times. You can  ...
   #include <iostream>   while                               using namespace std;                               int ma...
    Do...while                                                                                    /**                  ...
   #include <iostream>                                        using namespace std; // So the program                    ...
   The Infinite Loop:              #include <iostream>                                     using namespace std; int   A...
   While Loop             #include <iostream.h>                            int main(void) {                            i...
 Input : In any programming language input  means to feed some data into program.  Programming can be given in the form o...
Professor: Erwin M. Globio
Reena programming
Reena programming
Reena programming
Reena programming
Reena programming
Reena programming
Reena programming
Reena programming
Upcoming SlideShare
Loading in …5
×

Reena programming

176 views

Published on

Final Requirement- Fundamentals of Programming :)

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
176
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Reena programming

  1. 1. FINAL REQUIREMENTReena R. Perez http://eglobiotraining.com/
  2. 2. http://eglobiotraining.com/
  3. 3.  In programming, a switch, case, select or inspect statement is a type of selection control mechanism that exists in most imperative programming languages such as Pascal, Ada, C/C++, C# programming language , Java, and so on. http://eglobiotraining.com/
  4. 4. It is also included in several other types ofprogramming languages. Its purpose is toallow the value of a variable or expression tocontrol the flow of program execution via amultiway branch (or "goto", one of severallabels). The main reasons for using a switchinclude improving clarity, by reducingotherwise repetitive coding, and (if theheuristics permit) also offering the potential forfaster execution through easier compileroptimization in many cases. http://eglobiotraining.com/
  5. 5.  char key; C# In C# programming, every case  printf("Enter an arithmetic operatorn");  scanf("%c",&key); block that contains any statements must have a  switch (key) reachable end point, or triggers a  { compilation error.In  case +:  add(); programming usually, this is a  break; break statement, but any jump statement can be used – such as  case -: return, goto or throw – or the  subtract();  break; switch can simply end with an infinite loop. Case fall-through is  case *: only permitted when there are no  multiply(); statements between one case  break; statement and the next. If fall-  case /: through is otherwise desired, it  divide(); must be made explicit with the  break; goto case construct. C#  default: programming also allows the  printf("invalid keyn"); use of non-integer case  break; values, such as Strings.  } http://eglobiotraining.com/
  6. 6. #include<iostream>#include<stdlib.h>using namespace std;int main (){int number_of_units, tuitionfee, paymentforunits;cout<< "number of units you are to enroll:nn";cin>>number_of_units;paymentforunits=number_of_units*150;cout<<"payment for units:nn"<<paymentforunits;tuitionfee=paymentforunits+15%+20;cout<<"tuition fee:nn"<<tuitionfee;system("PAUSE");return 0;} http://eglobiotraining.com/
  7. 7.  Select Case n  Case Is < -5  MsgBox("n is less than -5") Visual Basic .NET  Case -4 To -1  MsgBox("n is between -4 and -1")  Case 0  MsgBox("n is 0") In programming, Visual  Case 2, 4, 6, 8 Basic .NET, the switch   MsgBox("n is even") Case 1, 3, 5, 7, 9 statement is called  MsgBox("n is odd") "Select Case   Case Else MsgBox("only single-digit numbers are programming", and fall-  allowed.", vbCritical) End Select through to later blocks is  not supported.   Visual FoxPro However, ranges and   Visual FoxPro: various constructs from If  Do Case statements are both   Case field_1 = "X" Replace field_b With 1 supported  Case field_1 = "Y"  Replace field_b With 2  Case field_1 = "Z"  Replace field_b With 3  Endcase http://eglobiotraining.com/
  8. 8.  #include<iostream> using namespace std; int main(void) { char grade; Haskell cout << "Enter your grade: "; cin >> grade; Haskells case construct, unlike C-influenced switch (grade) programming languages, has { no fall-through behaviour. It is case A: a programming expression cout << "Your average which returns a value, and it must be between 90 - 100" can deconstruct values using pattern matching. << endl; break; case B: cout << "Your average must be between 80 - 89" << endl; break; case C: cout << "Your average must be between 70 - http://eglobiotraining.com/ 79"
  9. 9. #include<stdlib.h>#include<iostream>using namespace std;int main(){char gender;cout<<"Enter your Gender.";cin>>gender;if (gender == M||gender == m)cout<<"Male";elsecout<<"Female";cout<<"nnn";system("PAUSE");return 0;} http://eglobiotraining.com/
  10. 10.  #include<iostream>  using namespace std; Pascal   int main() {  int a;  cin >> a; if ( a <= 10 ) In   { Programming, Pas  10" << n; cout << "Below cal does not allow   } else “fall through”, but  {  if ( a < 60 ) has ranges and  { comma separated  cout << "Below 60" << n; literal lists.   } }  return 0;  } http://eglobiotraining.com/
  11. 11.  #include<iostream>  using namespace std;  int main()  { Perl   char myinput; cin >> myinput;  switch (myinput) Perl 5.10 has a  {  case a: powerful built in  switch statement  cout << "Run program 1n"; called given, where  break; case b: the programming  { cases are called  cout << "Run program 2n"; when:  cout << "Please Waitn";  break;  }  default:  cout << "Invalid choicen";  break;  }  return 0;  } http://eglobiotraining.com/
  12. 12. #include<stdlib.h>#include<iostream>#include<stdio.h>#include<conio.h>using namespace std;int main(){float total_purchase=0, purchase_discount = 0, net_bill=0;cout<<"PLEASE INPUT TOTAL PURCHASE: ";cin>>total_purchase;if (total_purchase >=2000)purchase_discount = total_purchase*0.10;cout<<"THE DISCOUNT IS:";cout<<purchase_discount;net_bill = (total_purchase)-purchase_discount;cout<<"nYOUR NET BILL IS:";cout<<net_bill;system("PAUSE");return 0; http://eglobiotraining.com/}
  13. 13. http://eglobiotraining.com/
  14. 14. http://eglobiotraining.com/
  15. 15.  In programming, very often when you write code, you want the same block of code to run a number of times. You can use looping statements in your code to do this. In programming, the JavaScript programming have the following looping statements: While programming- loops through a block of code while a condition is true Do...while programming- loops through a block of code once, and then repeats the loop while a condition is true For programming- run statements a specified number of times http://eglobiotraining.com/
  16. 16.  #include <iostream> while  using namespace std;  int main() In programming  { while statement  int x; will execute a  x = 0; block of code while  do { a condition is true..  // "Hello, world!" is printed at least one time  // even though the condition is false  cout<<"Hello, world!n";  } while ( x != 0 );  cin.get();  } http://eglobiotraining.com/
  17. 17.  Do...while   /** ** This example contains a switch statement that performs  ** the same statement for more than one case label.  In Programming the  **/ do...while statement  #include <stdio.h> will execute a block of  int main(void)  { code once, and then it  int month; will repeat the loop  /* Read in a month value */  printf("Enter month: "); while a condition is  scanf("%d", &month); true  /* Tell what season it falls into */  switch (month)  The Java   { case 12: programming   case 1: case 2: language also   printf("month %d is a winter monthn", month); break; provides a do-while  case 3: statement, which can   case 4: case 5: be expressed as   printf("month %d is a spring monthn", month); break; follows:  case 6:  case 7:  case 8:  printf("month %d is a summer monthn", month);  break;  case 9:  case 10:http://eglobiotraining.com/  case 11:  printf("month %d is a fall monthn", month);  break;
  18. 18.  #include <iostream>  using namespace std; // So the program can see cout and endl for  int main()  { In programming the “for”  // The loop goes while x < 10, and x increases by one every loop statement will execute a block  for ( int x = 0; x < 10; x++ ) { of code a specified number of  // Keep in mind that the loop condition checks times  // the conditional statement before it loops again.  // consequently, when x equals 10 the loop breaks.  // x is updated before the condition is checked.  cout<< x <<endl;  }  cin.get();  } http://eglobiotraining.com/
  19. 19.  The Infinite Loop:  #include <iostream> using namespace std; int A loop becomes infinite main () { for( ; ; ) { loop if a condition never printf("This loop will run becomes false. The for forever.n"); } return 0; } loop is traditionally used for this purpose. Since none of the three expressions that form the for loop are required, you can make an endless loop by leaving the conditional expression empty. http://eglobiotraining.com/
  20. 20.  While Loop  #include <iostream.h> int main(void) { int x = 0; In int y = 0; bool validNumber = false; programming, Fo while (validNumber == false) { r repeating C cout << "Please enter an integer between 1 and 10: "; programming cin >> x; cout << "You entered: " << x << endl << endl; statements whiles if ((x < 1) || (x > 10)) { a condition is cout << "Your value for x is not between 1 and 10!" << endl; true,the while cout << "Please re-enter the number!" << endl << endl; provides a the } else necessary validNumber = true; } mechanism. cout << "Thank you for entering a valid number!" << endl; system("pause"); return 0; } http://eglobiotraining.com/
  21. 21.  Input : In any programming language input means to feed some data into program. Programming can be given in the form of file or from command line. C programming language provides a set of built-in functions to read given input and feed it to the program as per requirement. Output : In any programming language output means to display some data on screen, printer or in any file. C programming language provides a set of built-in functions to output required data. http://eglobiotraining.com/
  22. 22. Professor: Erwin M. Globio

×