In: Computer Science
Write a program in Easy68K:
a) Define an array of numbers in the memory.
b) Read two numbers from keyboard. The first number is the size of the array and the second number is what index of the array you want to access. The index you entered can be larger than the array.
c) Display the element indexed by (index % size) in the array.
#include<stdio.h>
int main()
{
int array[100];
printf("Enter the no of elements in the array");
int n , i ;
scanf("%d",&n);
for(i=0;i<n;i++)
{
array[i]=i*5;
}
printf("Enter the index of the array to be accessed");
int j;
scanf("%d",&j);
if(j<n)
printf("The element in %d index is %d",j,array[j]);
else
printf("The element in %d index is %d",j,array[j%n]);
}