Modified_code_in_which_I_have_taken_a_array_A__and_stored_square_of_all_elements_in_array_B[1]
Modified_code_in_which_I_have_taken_a_array_A__and_stored_square_of_all_elements_in_array_B[1]
elements in array A and there are also x elements in array B . Now I am taking square of each element of
A array and storing it in B array and new array that is square of array A is formed which was the required
program....*/
#include<stdio.h>
int main(){
int x;
scanf("%d",&x);
int a[x];
int b[x];
for(int i=0;i<x;i++){
scanf("%d",&a[i]);
for(int i=0;i<x;i++)
printf("%d ",a[i]);
for(int i=0;i<x;i++)
b[i]=a[i]*a[i];
for(int i=0;i<x;i++)
{
printf("%d,",b[i]);
return 0;
int tamp;
tamp=a[x-1];
a[x-1]=smallest;
a[smallestindex]=tamp;
printf("The array after swapping is :\n");
for(int i=0;i<x;i++)
{
printf("%d ",a[i]);
}
return 0;
}
int main() {
int x;
printf("How many elements do you want to enter in array\n");
scanf("%d",&x);
int a[x];
printf("Now enter the elements\n");
for(int i=0;i<x;i++)
{
scanf("%d",&a[i]);
}
int direction;
printf("In which direction do you want the shift ?\nEnter 1 for left shifts and 0 for right shifts\n");
scanf("%d",&direction);
if(direction==1)
{
int shifts;
printf("How many shifts do you want to perform\n");
scanf("%d",&shifts);
shifts=shifts%x;
while(shifts>0)
{
int temp=a[0];
for(int i=1;i<x;i++)
{
a[i-1]=a[i];
}
a[x-1]=temp;
shifts--;
}
}
else if(direction==0)
{
int shifts;
printf("How many shifts do you want to perform\n");
scanf("%d",&shifts);
shifts=shifts%x;
while(shifts>0)
{
int temp=a[x-1];
for(int i=x;i>0;i--)
{
a[i]=a[i-1];
}
a[0]=temp;
shifts--;
}
}
printf("So array after the desired number of shifts is is :\n");
for(int i=0;i<x;i++)
printf("%d ",a[i]);
return 0;
}