Traversing of elements program with algorithm and Flowchart
ALGORITHM
VARIABLES:
§ i: loop counter of array.
§ A: array name.
§ LB: lower bound.
§ UB: upper bound.
ALGORITHM:
STEP 1: set
i =LB
STEP 2: repeat steps 3 & 4
While i<=UB
STEP 3: apply process to A[i]
STEP 4: i = i+1
STEP 5: exit
EXPLANATION:
§ To
traverse the elements of the array, firstly set the loop counter ‘i’ equal to
last element of the array called the LOWER
BOUND.
§ Now,
repeat step 3 & 4 for accessing all the elements of the array until loop
counter ‘i’ is not less than or equal first element of array.
§ Now,
after checking the above condition, the whole process will repeat for all the
elements of array.
§ After
applying process upon a[i], increment the loop counter by 1, until the
condition is not satisfied.
IMPLEMENTATION
#include<stdio.h>
#include<conio.h>
void
main()
{
clrscr();
int
a[10];
int
i,n;
printf("enter
no of elements:");
scanf("%d",&n);
printf("enter
array:");
for(i=1;i<=n;i++)
{
scanf("%d",a[i]);
}
printf("entered
array is");
for(i=1;i<=n;i++)
{
printf("%d",a[i]);
}
getch();
}
thanks
ReplyDeletethanks
ReplyDeleteSuperb���� apke topics ko explain krne ka method bhut acha h....kafi tym s m y topic clear krna chach rhi thi but nh hua aj ho gya thanks....ek reqst h ap plz array ke other operations like insertion, deletion, modification& also merging plz uploAd kr dijiye.....
ReplyDeletethis program is wrong
ReplyDeleteIt's very easy
ReplyDeleteIska output bhi bta do please
ReplyDeleteThank you for sharing this on your blog! It is very helpful for my insight! Please update more posts about this. Would love to see more updates from you.
ReplyDeleteMelbourne Web Designer
Great .. you explained very well
ReplyDelete