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 |
how to implement stack work as a queue?
Can U write a C-program to print the size of a data type without using the sizeof() operator? Explain how it works inside ?
Why c++ is called c++ and not c+?
how to write hello word without using semicolon at the end?
main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); } output?
we all know about the function overloading concept used in C++ and we all learnt abt that.... but that concept is already came in C in a very smaller propotion ... my question is IN WHICH CONCEPT THERE IS A USE OF FUNCTION OVERLOADING IS USED in C language?????????????
What is meant by high-order and low-order bytes?
Is it possible to create recycle bin in mobiles?
What oops means?
Are the outer parentheses in return statements really optional?
diff .between strcture and union
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12