INPUT:Array with lower bound(l) and upper bound(u)
OUTPUT:ELEMENT PRESENT IN THE ARRAY
Data Structure: Single Dimensional Array
STEP 1: START
STEP 2: WHILE(i<=u)
STEP 3: PRINT(A[i])
STEP 4: ENDWHILE
STEP 5: STOP
Code
C
JAVA
C
#include <stdio.h>
int main()
{
int n;
printf("enter the limit ");
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
{
printf("enter the elements ");
scanf("%d",&a[i]);
}
for(int i=0;i<n;i++)
{
printf("%d ",a[i]);
}
return 0;
}
JAVA
import java.util.*;
class Traversal
{
public static void main(){
int a[]={1,2,3,4,6,7,9};
while(i<a.length&&flag==0)
{
System.out.println(a[i]);
}
}
}
Output
user@computer$ enter the limit 4
enter the elements 2
enter the elements 3
enter the elements 1
enter the elements 3
2 3 1 3