0

Whats is c++ program.. this first in algorithm. I dont undersand about c++ adress..

#include<iostream> using namespace std; int main() {cout<<"hello the world Im Mkh12"<<endl; return 0;}

27th Nov 2016, 8:31 AM
Mkholid Ra
Mkholid Ra - avatar
2 odpowiedzi
0
please i dont understand ..how make the program for looping and addres
27th Nov 2016, 8:32 AM
Mkholid Ra
Mkholid Ra - avatar
0
For a loop there are three options: - for -loop: for( int i = 0; i < n; i++){} first you set your index i to 0, then you write your condition for the loop, which will be checked before executing the loops's content. the last one increments the index by 1 after the loop has been executed - while -loop: while(i < n){} has pnly a condition, which will be checked before executing the loop's content. - do-while -loop: do{}while() The do-while loop is a little bit different. It has only one condition like the while-loop, but the do-while loop executes the content before checking the condition, so it will run at least once. Another point is, that you can form one loop into each other, e.g.: for( int i = 0; i < n; i++) { //content } ------------------------------------- int i = 0; while( i < n) { //content ++i; } note: 'n' is a specific variable or value in this example. Address: You can imagine addresses similar to a postbox for a multifamily house. Each postbox is analog to one of your storage places allocated by an array of yours. So if you take the reference (address) of your array, it will take the address of your first element in the array. This would be the first post box in our example. When you increase the address by 1, you will get the next postbox respectively storage place in the array. Example: int xyz[3] = {1,2,3}; // Create an array of size 3 int* a = xyz; // Store the address of the array in a pointer. // The pointer now holds the address of the first element. int x = xyz[0]; // take first element in array int x_p = *a; // now x and x_p should be equal and hold the value 1 int y = xyz[1]; // take second element in array int y_p = *(a+1); // now y and y_p should be equal and hold the value 2 int y = xyz[2]; // take third element in array int y_p = *(a+2); // now z and z_p should be equal and hold the value 3
27th Nov 2016, 9:38 AM
Andreas K
Andreas K - avatar