Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PREDEFINED FUNCTIONS
- //______________________________________________________________
- // a predefined function is something already created by somebody else for you to use
- //function prototype (declaring its there but nothing within it)
- //int numbers(int num1, int num2);// 1st int - return type, function name - add, parameters - (int num1, int num2)
- /*int main()
- {
- cout << "8 + 1 + 1" << endl;
- // funciton call
- cout << numbers(8, 1) << endl;
- system("pause");
- return 0;
- }
- // function body
- int numbers(int num1, int num2)
- {
- return num1 + 1 + num2;
- }
- int main()
- {
- // cos is a pre-defined dunction that calculates the cosone of the target (number)
- cout << cos(5.5) << endl;
- system("pause");
- return 0;
- }
- _________________________________________________________________________________________
- //GLOBAL and LOCAL Variables
- int num = 10;// - declares it and affects the whole file instead of it being in int main (can access iy anywhere)
- void printName();
- int main()
- {
- // local variables - delcared but can only be used inside the function so in this case it can only be used inside main
- // global
- printName();
- system("pause");
- }
- void printName()
- {
- for (int i = 0; i < num; i++)
- {
- cout << "Joshua" << endl;
- }
- }
- ___________________________________________________________________________________________
- // fixed loop
- for (int = 0;i < 11; i++)
- {
- cout << i << endl;
- }
- // post checked loop
- int a = 20;
- do
- {
- cout << "hello"
- } while (a != 20);
- // pre checked loop
- int a = 5;
- while (a != 5)
- {
- cout << "hello" << endl;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement