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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is s in c?

1047


How do we declare variables in c?

1058


How can I make it pause before closing the program output window?

1035


What is the difference between constant pointer and constant variable?

1220


What is masking?

1151


Does * p ++ increment p or what it points to?

1117


There seem to be a few missing operators ..

1047


List out few of the applications that make use of Multilinked Structures?

2187


please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................

2011


What are the 4 data types?

1012


What are the 5 types of organizational structures?

1071


Is it valid to address one element beyond the end of an array?

1167


What would be an example of a structure analogous to structure c?

996


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

1088


What is the method to save data in stack data structure type?

1080