Rotating the elements of an array data structure by k positions to the right.
Get link
Facebook
X
Pinterest
Email
Other Apps
-
#include <stdio.h>
// K is no.of positions an array to be rotated
int main()
{
int k=2 , n=4,a[4]={1,2,3,4}, b[4],i;
for(i=0;i<n;i++)
{
b[(i+k)%n]=a[i];
}
for(i=0;i<n;i++)
{
printf("%d\t",b[i]);
}
return 0;
}
/* Program to know the range of short signed integer*/ #include <stdio.h> #include <limits.h> int main() { short int var1 = SHRT_MIN; short int var2 = SHRT_MAX; printf("range of short signed integer is from %d to %d",var1,var2); return 0; }
int main() { int i,j,temp,x,y; int a[]={16,70,8,100,9,85}; int n = sizeof(a)/sizeof(a[0]); for(i=0;i<n-1;i++) { for(j=i+1;j<n-1;j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j] = temp; ...
Comments
Post a Comment