1 / 8

Basic Structures

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.

abram
Download Presentation

Basic Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Basic Structures • Structured Programming in C/C++ • sequence • decision/selection/testing • iteration/repetition/looping e-business and Information Systems

  2. Sequence //Do this instruction int iCount = 0; int iRow = 0; int iColumn = 0; e-business and Information Systems

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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

  8. Variable declarations All variable declarations must be done at the beginning of the block. e-business and Information Systems

More Related