Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// 4. conditions and loops
- #include<bits/stdc++.h>
- using namespace std;
- signed main(){
- int a,b;
- cin >> a >> b;
- /* condition operators:
- (==) equals to
- (!=) not equals to
- (>) more than
- (<) less than
- (>=) at least
- (<=) at most
- logic operators:
- (&&) and
- (||) or
- (!) not
- */
- /// condition statements
- if(a>b && a>=2){ // curly brackets
- // if the condition is true, do something
- } // End If
- else{
- // else, do the other thing
- }
- /// loops
- for(int i=0;i<=5;i++){ // For i As Integer = 0 To 5 Step 1
- // do something
- cout << i << endl;
- }
- int i=10;
- while(i>=0){ // Just like While loop in VB
- // do something
- cout << i << endl;
- i--; // means i = i-1
- }
- /// ** Don't forget to add ';' at the end of the statement **
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement