POINTER -26
Problem Description
Write a program to compare two arrays using pointers.
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 a,b,i,j,f;
scanf("%d",&a);
int arr[a];
for(j=0;j<a;j++)
{
scanf("%d",&arr[j]);
}
scanf("%d",&b);
int arr1[b];
for(i=0;i<b;i++)
{
scanf("%d",&arr1[i]);
}
for(i=0;i<a;i++)
{
if(arr[i]!=arr1[i])
{
f=1;
break;
}
}
if(f==1)
printf("Arrays are not equal");
else
printf("Arrays are equal");
return 0;
}
Test Case 1
Input (stdin)5
1 2 3 4 5
5
5 4 3 2 1
Expected Output
Arrays are not equal
Test Case 2
Input (stdin)4
1 2 3 4
4
1 2 3 4
Expected Output
Arrays are equal
No comments:
Post a Comment