Answers for "python is god"

0

python is god

#include<iostream>

int main()
{
    std::cout << "Hello, new world!\n";
}

/*Create an Array*/
int marks[5] = { 96, 92, 78, 54, 86};

/*IF ELSE*/
if(num % 2 == 0)
{
    cout << "Number divisible by 2" << endl;
}
else if(num % 3 == 0)
{
    cout << "Number divisible by 3" << endl;
}
else
{
    cout << "Bad Number" << endl;
}

/*FOR Loops*/
// fetch each array-element and print it out
int arr[] = {1,2,3,4,5,6};

for(int n : arr)
{
    cout << n << endl;
}

/*
  Warning: the example above will reference the original memory of arr[] and has write-access!

  As you often don't need to write to that adress-space, you should consider to access it read-only for safety reasons.
  To avoid write-access, you might consider using a const-reference like shown below,
  which will create a constant -and therefore unchangeable- reference named "n" to each existing value of "arr",
  effectively referncing the values read-only.

  You'll learn more about reference's and pointer's in the next chapters.
*/

// fetch each array-element and print it out (readonly)
int arr[] = {1,2,3,4,5,6};

for(const int& n : arr)
{
    cout << n << endl;
}
Posted by: Guest on May-29-2021

Browse Popular Code Answers by Language