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 |
Can include files be nested?
Explain what are the different data types in c?
write a c program to check weather a particluar bit is set or not?
What are structure members?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
Write the syntax and purpose of a switch statement in C.
how to find the largest element of array without using relational operater?
what is the difference between #include<stdio.h> and #include "stdio.h" ?
I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.
do you think its fraud or original company?
change to postfix a/(b+c*d-e)
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol