Pages

Friday, 26 February 2016

C Language program to shift array element with previous one


/* Girfa : C Language program to shift array element with previous one*/
/* Find more question Answer on http://girfahelp.blogspot.in/2012/09/some-program-of-c-language.html */
#include<stdio.h>
#include<conio.h>
void main()
{
int ar[5],i,j;
clrscr();
for(i=0;i<5;i++)
ar[i]=i+1;

printf("\nOriginal Array\n");
for(i=0;i<5;i++)
printf("\t%d",ar[i]);
j=ar[0];

for(i=0;i<5-1;i++)
{
ar[i]=ar[i+1];
}
ar[i]=j;
printf("\nAfter replace \n");
for(i=0;i<5;i++)
printf("\t%d",ar[i]);

getch();
}

No comments:

Post a Comment