C programme to cyclically permute the elements of an array A. i.e. the content of A1 become that of A2.And A2 contains that of A3 & so on as An contains A1

by Nideesh C on April 12, 2011 · 0 comments

in C Programming




/*  C programme to cyclically permute the elements of an array A.  i.e. the content of A1 become that of A2.And A2 contains that of A3  & so on as An contains A1  */

#include <stdio.h>

void main ()
{
int i,n,number[30];
printf(“Enter the value of the n = “);
scanf (“%d”, &n);
printf (“Enter the numbers\n”);
for (i=0; i<n; ++i)
{
scanf (“%d”, &number[i]);
}
number[n] = number[0];

for (i=0; i<n; ++i)
{
number[i] = number[i+1];
}
printf (“Cyclically permuted numbers are given below \n”);
for (i=0; i<n; ++i)
printf (“%d\n”, number[i]);
}
/*————————————-
Output
Enter the value of the n = 5
Enter the numbers
10
30
20
45
18
Cyclically permuted numbers are given below
30
20
45
18
10
—————————————————*/

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C Program to accept N integer number and store them in an array AR. The odd elements in the AR are copied into OAR and other elements are copied into EAR. Display the contents of OAR and EAR
  2. C program to read N integers and store them in an array A, and so find the sum of all these elements using pointer. Output the given array and and the computed sum with suitable heading
  3. C program to sort given N elements using SELECTION sort method using functions a) To find maximum of elements b) To swap two elements
  4. C program to read in four integer numbers into an array and find the average of largest two of the given numbers without sorting the array. The program should output the given four numbers and the average with suitable headings.
  5. C program to read a matrix A (MxN) and to find the following using functions a) Sum of the elements of each row b) Sum of the elements of each column c) Find the sum of all the elements of the matrix Output the computed results with suitable headings

Leave a Comment

Previous post:

Next post: