Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Program to swap the any two elements in an array containing N number of elements?



Program to swap the any two elements in an array containing N number of elements?..

Answer / baluusa8

#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

Post New Answer

More C Interview Questions

Should I learn data structures in c or python?

0 Answers  


Explain what are the advantages and disadvantages of a heap?

0 Answers  


What is that continue statement??

4 Answers  


What is wrong in this statement? scanf(“%d”,whatnumber);

0 Answers  


Is Exception handling possible in c language?

0 Answers   Wipro,


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?

0 Answers   TCS,


How does free() know explain how much memory to release?

0 Answers  


Write a program to use switch statement.

0 Answers   Agilent, Integreon, ZS Associates,


what is the similarities between. system call and library function?

1 Answers   Wipro,


How to reverse alternate words in a given line of string For Eg: my name is narasimha output : my eman is ahmisaran

0 Answers  


why Language C is plateform dependent

3 Answers   Siemens, Wipro,


How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?

2 Answers   Aricent, Manipal University,


Categories