Write a c program for swapping of two arrays ?
#include<stdio.h>
int main()
{
int str1[100],str2[100],str3[100],i;
printf("Enter First array->");
for (i=0;i<100;i++)
scanf("%d",&str1[i]);
printf("\nEnter Second array->");
for (i=0;i<100;i++)
scanf("%d",&str2[i]);
printf("Arrays before swapping");
printf("\nFirst array->");
for (i=0;i<100;i++)
{
printf("%d",str1[i]);
}
printf("\nSecond array->");
for (i=0;i<100;i++)
{
printf("%d",str2[i]);
}
for (i=0;i<100;i++)
{
str3[i]=str1[i];
str1[i]=str2[i];
str2[i]=str3[i];
}
printf("\nArrays after swapping");
printf("\nFirst array->");
for (i=0;i<100;i++)
{
printf("%d",str1[i]);
}
printf("\nSecond array->");
for (i=0;i<100;i++)
{
printf("%d",str2[i]);
}
return 0;
}
#include<stdio.h>
int main()
{
int str1[100],str2[100],str3[100],i;
printf("Enter First array->");
for (i=0;i<100;i++)
scanf("%d",&str1[i]);
printf("\nEnter Second array->");
for (i=0;i<100;i++)
scanf("%d",&str2[i]);
printf("Arrays before swapping");
printf("\nFirst array->");
for (i=0;i<100;i++)
{
printf("%d",str1[i]);
}
printf("\nSecond array->");
for (i=0;i<100;i++)
{
printf("%d",str2[i]);
}
for (i=0;i<100;i++)
{
str3[i]=str1[i];
str1[i]=str2[i];
str2[i]=str3[i];
}
printf("\nArrays after swapping");
printf("\nFirst array->");
for (i=0;i<100;i++)
{
printf("%d",str1[i]);
}
printf("\nSecond array->");
for (i=0;i<100;i++)
{
printf("%d",str2[i]);
}
return 0;
}
No comments:
Post a Comment