/* 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; }
First we should have a sorted array in order to compare with the input what we have given so we can know how many times it is sorted. a[] = {2,3,6,12,15,18}. int main() { int a[]={15,18,2,3,6,12}; int n = sizeof(a)/sizeof(a[0]); int count = countRotations(a,n); printf("%d",count); return 0; } int countRotations(int a[],int n) { int min = a[0],x; for(int i=0;i<n;i++) { if(min>a[i]) { min = a[i]; x = i; } } ...
/* Program to know the range of unsigned integer*/ #include <stdio.h> #include <limits.h> int main() { int var1 = 0; int var2 = UINT_MAX; printf("range of unsigned integer is from %u to %u",var1,var2); return 0; }
Comments
Post a Comment