Answer to Question #199059 in C for Ayesha

Question #199059

Write a program that swaps values between different locations in a two dimensional array. Make sure that the locations between which the values are being exchanged are symmetric.


1
Expert's answer
2021-05-27T01:57:30-0400
#include<stdio.h>


int main()
{
    int Size, i, a[10], b[10], Temp[10];
    printf("\nPlease Enter the Size of the Array\n");
    scanf("%d", &Size);
    printf("\nPlease Enter the First Array Elements\n");
    for(i = 0; i < Size; i++)
    {
        scanf("%d", &a[i]);
    }
    printf("\nPlease Enter the Second Array Elements\n");
    for(i = 0; i < Size; i ++)
    {
        scanf("%d", &b[i]);
    }
    for(i = 0; i < Size; i++)
    {
        a[i] = a[i] + b[i];
        b[i] = a[i] - b[i];
        a[i] = a[i] - b[i];
    }
    printf("\n a[%d] Array Elements After Swapping \n", Size);
    for(i = 0; i < Size; i ++)
    {
      printf(" %d \t ",a[i]);
    }
    printf("\n\n b[%d] Array Elements After Swapping \n", Size);
    for(i = 0; i < Size; i ++)
    {
        printf(" %d \t ",b[i]);
    }
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS