90 likes | 224 Views
Basic Structures. Structured Programming in C/C++ sequence decision/selection/testing iteration/repetition/looping. Sequence. //Do this instruction. int iCount = 0; int iRow = 0; int iColumn = 0;. Sequence of Instructions.
E N D
Basic Structures • Structured Programming in C/C++ • sequence • decision/selection/testing • iteration/repetition/looping e-business and Information Systems
Sequence //Do this instruction int iCount = 0; int iRow = 0; int iColumn = 0; e-business and Information Systems
Sequence of Instructions Computer executes a sequence of instructions step-by-step from the top of the instruction and down. e-business and Information Systems
Variable and Function Declarations //variable declarations int myCounter; int myIndex = 0; //function declarations int myFirst(); int mySecond(int x); void myThird(int, int); e-business and Information Systems
Variable and Function //variable declarations int myCounter; int myIndex = 0; //function declarations int mySecond(int x); myCounter = 8; int iNumber = 2 * myCounter; int iSecondNumber = 7 + mySecond(5); e-business and Information Systems
Block of Instructions A block of related instructions is enclosed with an open and an close braces. Example: void main(){ int i = 0; { int y = 8; int x = 5 + i; } //end of block i = 29; } //end of main e-business and Information Systems
Example #include <stdio.h> void main() { int i = 0; int y = 0; int x; printf("Please enter an integer: "); scanf("%d", &y); x = 5 + y; { //beginning of a block int k = 6; i = x + k; printf("x is: %d and i is: %d \n", x, i); } //end of the block printf("x is: %d and y is: %d \n", x, y); } //end of main e-business and Information Systems
Variable declarations All variable declarations must be done at the beginning of the block. e-business and Information Systems