Program to swap the any two elements in an array containing N number of elements?
#include<stdio.h>
void swaparray(int *,int *);
void main()
{
int n,num[10],i,element,k,l;
printf("Enter number of elements
");
scanf("%d",&n);
printf("Enter the elements
");
for(i=0;i<n;i++)
{
scanf("%d",&element);
num[i]=element;
}
printf("Original array
");
for(i=0;i<n;i++)
printf("num[%d]=%d
",i,num[i]);
printf("ENter places to be swapped");
scanf("%d%d",&k,&l);
swaparray(num+k,num+l);
printf("AFTER SWAPPING
");
for(i=0;i<n;i++)
printf("num[%d]=%d
",i,num[i]);
}
void swaparray(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
| Is This Answer Correct ? | 7 Yes | 1 No |
Should I learn data structures in c or python?
Explain what are the advantages and disadvantages of a heap?
What is that continue statement??
What is wrong in this statement? scanf(“%d”,whatnumber);
Is Exception handling possible in c language?
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?
How does free() know explain how much memory to release?
Write a program to use switch statement.
0 Answers Agilent, Integreon, ZS Associates,
what is the similarities between. system call and library function?
How to reverse alternate words in a given line of string For Eg: my name is narasimha output : my eman is ahmisaran
why Language C is plateform dependent
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
2 Answers Aricent, Manipal University,