Advertisement
pcwizz

how to code in: c++ 1

Jun 8th, 2012
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. //include
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. //show off functions that aren't main
  6. void function();
  7. //functions
  8. int main(){
  9. //variables
  10. int number;
  11. double numberwithpoint;
  12. bool torf;
  13. char letter;
  14. //arrays of variables
  15. int numberarray[];
  16. double numberwithpointarray[];
  17. bool torfarray[];
  18. char letterarray[];
  19. // testing and loops
  20. //switch statment
  21. switch(avariable){
  22.     case something:
  23.    
  24.     break;
  25.     default:
  26.     //somthing to do
  27.     }
  28. //if statment
  29. if(something){
  30.    
  31.    
  32.     }
  33.     else if(somthingelse){
  34.        
  35.         }
  36.     else{
  37.        
  38.        
  39.         }
  40. //while loop
  41. int i;
  42. while(i < 10){
  43.     cout << "i is less than 10" << endl;
  44.     i++;
  45.     }
  46. //do while
  47. do{
  48.    
  49.     }while(something);
  50. //for loop
  51. for(int var; var <= 42; var++){
  52.     cout << var << endl;
  53.    
  54.     }
  55.  
  56. //in points using goto
  57. loop:
  58. //do something
  59. if(something) goto loop;
  60. //run you other funtion
  61. function();
  62. //return 0 no signal for os to handle after program end.
  63. return 0;
  64. }
  65. //a second function
  66. void function(){
  67.     //functions stuff
  68.     //print some text on the screen using the iostream libary
  69.     cout << "some text" << endl;
  70.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement