Follow

Translate

Saturday, April 30, 2016

/* Another Methods of Traversing in a Linear Array  */

#include<stdio.h>         /* Header File that are called standard input output*/
#include<conio.h>        /* Header File that are called consol input output*/

void main(){       /*start the main function and void that are not return type*/

clrscr();            /* Clear the screen at every time when input new element*/

int LA[] = {20, 65, 73, 88, 33, 95, 25};   /*array that will be stored 5 element*/ 

int k,count =0, LB=0,UB=7;    /*only declare that are integer variable*/
k=LB;
printf("\nThe array contain.....\n");/*Only for print that mean get the output  */

for(k=LB;k<UB;k++){                       /*that are loop k=0,UB=5*/
printf("%d\t", LA[k]);
k++;                           /*increase the loop element */
count++;                  /*to be increase for counting in the array*/

printf("\n\n The number of elements=%d", count);  /* Count the element of array */
getch();   /*keep to stay the screen*/   
}


            index=0,1,2,3,4 there are 5 index element since, there have 5 element that are 5,6,7,8,3
                        0 1 2 3 4

Note:    0=5,1=6,2=7,3=8,4=3

So, when 0<5 that are condition is true and print 0 index that are mean 5 print stil condition 4<5 will be print that are 3 element and next condition 5<5 that are false condition and exit loop.
Here, when print o index and increase the value of loop the 1 and continue 4 and will be exit loop when value is 5.

If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

0 comments:

Post a Comment