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 |
implement NAND gate logic in C code without using any bitwise operatior.
Can two or more operators such as and be combined in a single line of program code?
What are pointers? Why are they used?
Explain what is the benefit of using const for declaring constants?
what is the difference between normal variables and pointer variables..............
15 Answers HP, Infosys, Satyam, Vivekanand Education Society,
Combinations of fibanocci prime series
What is the difference between array and pointer?
Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor
what is the difference between c and java?
write a program to convert a expression in polish notation (postfix) to inline (normal)
An array name contains base address of the array. Can we change the base address of the array?
Why doesn't C have nested functions?