All pastes #480181 Raw Edit

Untitled

public cpp v1 · immutable
·published 2007-05-10 03:42 UTC
rendered paste body
By Matt N;heres a example of making code shorter:#include <iostream>using namespace std;int main(){cout << "Hello" << endl;cout << "Hello" << endl;cout << "Hello" << endl;cout << "Hello" << endl;cout << "Hello" << endl;cout << "Hello" << endl;cout << "Hello" << endl;cout << "Hello" << endl;cout << "Hello" << endl;cout << "Hello" << endl;return(0);}Outputs: HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloYou can make that code alot faster, more efficient and flexable by doing it like this:#include <iostream>using namespace std;void HelloFriend(){for(int i = 0; i <= 10; i++){cout << "Hello" << endl;}}int main(){HelloFriend();return(0);}Outputs:HelloHelloHelloHelloHelloHelloHelloHelloHelloHello Shorter and better!Lets explain: i = 0, thats simple enough, i <= 10 means if i is less or equal to 10, i++ means add 1. so if i = 0, i++ will make it 1, and so on.Now this is how it works, if i is less or equal to 10 output Hello, else, nothing. So each time it outputs hello i's value increases by 1 making it closer to ten, once it becomes 11 its no longer equal or less than 10 therefore stopping.