Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Sunday, 5 June 2016

PROBLEM 25:

Write a program that tests equality of two array of size , suppose there are
two int array, The program should say “yes” if every element of first array is equal to the
corresponding element of second array, other wise no if at least one element is not equal .
Sample Input: First_Array 1 13 1 4 20 5
Second_Array 0 13 1 4 20 5
Sample Output: NO
Sample Input: First_Array 1 13 1 4 20 5
Second_Array 1 13 1 4 20 5

Sample Output : Yes

CODE:

#include<stdio.h>
main()
{
int a[25],b[25];
int count=0,i,n,count1=0;
printf("How many numbers you want to enter in both array:");
scanf("%d",&n);//here enter length of array
printf("Enter first array\n");
for(i=0;i<n;i++)   //this loop will run run until not equal to length of array
{
count1=count1+1; //here if condition is true so increment in count
printf("Enter %d number:",count1);
scanf("%d",&a[i]);
}
printf("Enter second array\n"); //here enter second array numbers
count1=0;
for(i=0;i<n;i++)
{
count1=count1+1;
printf("Enter %d number:",count1);
scanf("%d",&b[i]);
}
for(i=0;i<n;i++)
{
if(a[i]==b[i])//array one is equal to second array so increment will perform
{
count=count+1;
}
}
if(count==n) // if count is equal to total number of array so this condition will run
{
printf("yes");
}
else
{
printf("no");
}
return 0;
}

Program Output:















For more problems click here

No comments:

Post a Comment