Problem Description
Write a program using pointers to search a value from an array using pointer
Input and Output Format:
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.CODING ARENA
#include <stdio.h>
int main()
{
int array[100],search,c,n;
scanf("%d",&n);
for(c=0;c<n;c++)
scanf("%d",&array[c]);
scanf("%d",&search);
for(c=0;c<n;c++)
{
if(array[c]==search)
{
printf("%d is found in the array at position=%d",search,c);
break;
}
}
if(c==n)
printf("%d Does not exist in the array",search);
return 0;
}
Test Case 1
Input (stdin)3 45 67 89 99
Expected Output99 Does not exist in the array
Test Case 2
Input (stdin)3 45 67 89 67
Expected Output67 is found in the array at position=1
Write a program using pointers to insert a value in an array.
ReplyDeleteInput and Output Format:
Refer to sample input and output for formatting specification.
All float values are displayed correctly to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.