Home / EG Comp Lab / C Language / Swap even number with odd number and vice-versa: C Program

# swap even odd number

### C program to swap even position numbers with odd position numbers and vice-versa

This C program swap or vice-versa even and odd numbers.For example consider i.e. m[0]=1, m[1]=2  after swapping we get m[0]=2 and m[1]=1.

[message_box title=”PROGRAM” color=”yellow”]

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

#include <stdio.h>
#include <conio.h>

void main()

{

int m[20], i, n, temp, limit;

clrscr();

printf (” How many elements ? \n”);

scanf (“%d”, n );

printf (” Enter % d  elements below \n”,n);

for(i=0; i<n; ++i )

{

scanf ( “%d”, &m[i] );

}

if ( n%2==0 )

{

limit =n;

}

else

{

limit =n-1;

}

for( i=0; i<limit; i+=2 )

{

temp=m[i];

m[i]=m[i+1];

m[i+1]=temp;

}

printf ( “After Swapping \n” );

for( i=0; i<n; ++i )

{

printf( ” %d \n  “, m[i] );

}

}

[/message_box]

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

/* Written by Utpal Chaudhary  */

/* Student of L.D COLLEGE OF ENGINEERING, Ahmedabad-15, Gujarat */

I am third year student of computer engineering in L.D COLLEGE OF ENGINEERING,Ahmedabad.

## Game-Theoretic Pricing for Video Streaming in Mobile Networks

ABSTRACT Mobile phones are among the most popular consumer devices, and the recent developments of …