-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShifthingArrayElements_Method2.c
52 lines (43 loc) · 1.63 KB
/
ShifthingArrayElements_Method2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
$$$$$$$\ $$\ $$\ $$\ $$$$$$$$\
$$ __$$\ $$$\ $$ | $$ | \__$$ __|
$$ | $$ |$$\ $$\ $$$$\ $$ | $$$$$$\ $$$$$$\ $$ | $$ | $$$$$$\ $$\ $$\
$$$$$$$\ |$$ | $$ | $$ $$\$$ |$$ __$$\ $$ __$$\ $$ | $$ |$$ __$$\ $$ | $$ |
$$ __$$\ $$ | $$ | $$ \$$$$ |$$ / $$ |$$$$$$$$ |$$ | $$ |$$ / $$ |$$ | $$ |
$$ | $$ |$$ | $$ | $$ |\$$$ |$$ | $$ |$$ ____|$$ | $$ |$$ | $$ |$$ | $$ |
$$$$$$$ |\$$$$$$$ |$$\ $$ | \$$ |\$$$$$$ |\$$$$$$$\ $$ | $$ |\$$$$$$ |\$$$$$$$ |
\_______/ \____$$ |$ | \__| \__| \______/ \_______|\__| \__| \______/ \____$$ |
$$\ $$ |\_/ $$\ $$ |
\$$$$$$ | \$$$$$$ |
\______/ \______/
*/
#include<stdio.h>
#include<stdlib.h>
void main()
{
int a[20],limit,i,j,shift,temp;
printf("\nEnter the number of elements:");
scanf("%d",&limit);
printf("\nEnter the elements into the array:");
for(i=0;i<limit;i++)
{
printf("\nEnter value for a[%d]:",i);
scanf("%d",&a[i]);
}
printf("\nEnter the shift factor:");
scanf("%d",&shift);
for(i=0;i<shift;i++)
{
temp=a[0];
for(j=0;j<limit;j++)
{
a[j]=a[j+1];
}
a[j-1]=temp;
}
printf("\nThe array after the shifting is:");
for(i=0;i<limit;i++)
{
printf("\nThe value of a[%d]:%d",i,a[i]);
}
}