I need basic help with the layout and writing of the following code. It does not
ID: 3837646 • Letter: I
Question
I need basic help with the layout and writing of the following code. It does not need to be completely done for me but I am not sure how to get started on writing this...
Write a program that uses an array to store a series of integers. The program should prompt the user to enter elements into the array. After the array has been filled, it should display the initial contents of the array. It should then perform operations to manipulate the elements of the array through specific functions. Note that if the array is modified in any way, the program should re-display the contents of the array. The specific functions that should be used are: input (), display(), statistics (), count(), search(), replace(), modify(), and clear(). Write the code to control the execution of our program and to test each operation of the array within the body of the main() function.
Explanation / Answer
#include<stdio.h>
main()
{
int len,i,s,flag=0;
printf("Enter the Length Of the Array:");
scanf("%d",&len);
int arr[len];
printf("Taking Input ");
for(i=0;i<len;i++)
{
printf("Enter the data:");scanf("%d",&arr[i]);
}
printf(" Display Input ");
for(i=0;i<len;i++)
{
printf("%d ",arr[i]);
}
printf(" Searching The Particular Element:: ");
printf("enter the element you want to search:");scanf("%d",&s);
for(i=0;i<len;i++)
{
if(arr[i]==s)
{
flag=1;
}
}
if(flag)
{
printf("Element Found ");
}
else
{
printf("Element Not found ");
}
printf(" Replacing ");
int rep,rep1,x=-1,y=0;
printf("Enter on whihch number you want to replace:");scanf("%d",&rep);
printf("Enter on what number you want to replace:");scanf("%d",&rep1);
for(i=0;i<len;i++)
{
if(arr[i]==rep)
{
x=i;
}
else
{
y=1;
}
}
if(y=1)
{
printf("Element you wants to replace was not found");
}
arr[x]=rep1;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.