TRAVERSING ARRAY
TRAVERSING ARRAY:-
ALGORITHM:-
STEP1. SET K=LB
STEP2. REPEAT STEP 3 & 4 WHILE K<=UB
STEP3. VISIT ELEMENT LA[K]
SET K :=K|+1
STEP4. EXIT
CODE:-.
#include<stdio.h>
#include<conio.h>
void main() {
int a[5], i, size = 5;
clrscr();
printf("Enter array elements:\n");
for (i = 0; i < size; i++) {
scanf("%d", &a[i]);
}
printf("Array elements during traversal:\n");
for (i = 0; i < size; i++) {
printf("%d ", a[i]);
}
printf("\n");
getch();
}
Comments
Post a Comment
Kaushikmadhav77@gmail.com