//'i' can be any number
//Can be any comparison operater
//can be any number compared
//can be any mathmatic operater
for (int i = 0; i<100; i++){
//Do thing
}
//more info on operaters
//https://www.w3schools.com/cpp/cpp_operators.asp
#include <iostream>
using namespace std;
int main()
{
for (int i = 0; i < 20; i++)
{
cout << i << endl;
}
//prints the number (i)
}
for (int i = 0; i < 10; i++){
//Do something as long as i is less than 10,
//In that case it will loop 10 times
//use break; to restart the loop whenever you want to cancel the loops.
cout << i;
//at the end, remember i will be increased by 1.
}
//output 0123456789
for (let i=0; i<10; i++) {
console.log("hello") }
//I think this is a better way for a for loop
//for like going through arrays or something
//hope you like it :)
//be sure to do #include <set>
int main()
{
set<char> letters = {'A', 'B', 'C'};
for (auto itr = letters.begin(); itr != letters.end(); ++itr){
cout << *itr << endl;
}
}
for ( int i = 0; i < 5; i++)
{
cout << "Hello" << endl;
}
// prints hello 5 times.
for (int i = start; i < stop; i = i + step){
// statement 1
// statement 2
// etc
}
for (<exp_1>; <exp_2>; <exp_3>){
// loop body
}
for(int i=0;i< /*condition*/ ;i++)
{
//your code here
}
for (int i=0; i<10; ++i);
for (/* init var */;/* break condition */;/* mathmatic operation */) {
// do something
}
for ( init; condition; increment ) {
statement(s);
}
Example:
for ( i=0; i<5; i++ ) {
cout<<"Hello World"<<endl; //Hello World is going to be print out 5 times
}
for (int i = 0; i < 5; i++) {
cout << i << "
";
}
// i doesn't have to be defined as i, it could be any letter or word
// i < 10 means the code will loop 10 times before it ends
// i always starts at 0 unless you define it
// i++ means it increments by 1 every loop, can be any math function
for (int i; i<10; i++){
// Your code
}
// Great website to learn cpp: http://learn.onlinegdb.com/c%2B%2B_loops
int maxValue = 50;
for (int i = 0 ;i < maxValue;i++){
cout<<i<<endl;
}
int i;
for ( i=0; i<100; i++)
{
Excuted Code .....
}
// REMEMBER TO REPLACE '???'
// with the data structure to iterate on
for(int i=0; i<???; ++i) {}
for(auto it=???.begin(); it!=???.end(); ++it) {}
for(auto &obj : ???) {}
for(initialization; condition ; increment/decrement) {
statement(s);
}
int i;
for (i=0; i<10; i++) {
cout << i << endl;
}
for (initialization; condition; update) {
// body of-loop
}
// lets use for loop
for(int i=0;i<10;i++)
{
cout<<"hallo world";
}
for(int k = 1; k <= c ; k +=2){
}
for (int i = 0; i < some_int; ++i){
//do something here in loop - loop will run some_int - 1 times
}
for ( initialization;condition;increment ) {
statement(s);
}
for (i = 0; i < 20; i++){
cout << i << endl;
}
for (int i = 0; i < 7; i++)
{
cout << i << endl;
}
#include <iostream>
#define FOR(i,a) for (int i = 0; i < a; i++)
FOR(i, 3) cout << i << endl;
for loop
Code Example |
---|
Cpp :: a function to create double quotes for alphabet in c++ |
Cpp :: c++ influenced |
Cpp :: opengl text rendering with 3d rendering |
Cpp :: how to implement binders and decorators on c++ lik python? |
Cpp :: why ostream cannot be constant |
C :: C output color font |
C :: find string in all files powershell |
C :: terminal size in c |
C :: get file extension from base64 string |
C :: factorial c program using for loop |
C :: sstf program in c |
C :: random number in c |
C :: c code to python code converter online |
C :: c data types |
C :: remove from string c |
C :: Succ de ch |
C :: how to read character from a string in c |
C :: c round function |
C :: how to sleep in c |
C :: ROUNDING decimal number in C |
C :: How to change an array in a function in c |
C :: c language time() function |
C :: how to reverse a string in c |
C :: C scanf() to read a string |
C :: add_to_cart how to call it woocommerce |
C :: round float in c |
C :: c in to str |
C :: lichess puzzles |
C :: rfid rc522 code |
C :: c language |