Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- //logic to scale colours based on range
- int main() {
- int minD=99;
- int maxD=2000;
- unsigned int range= abs(maxD-minD);
- printf("Range: %d\n", range );
- //
- int result = range / 7;
- int remainder = result % 7;
- int spectrum = result - remainder;
- printf("spectrum: %d\n",spectrum);
- int depth_value=20;
- if(depth_value>minD &&depth_value<maxD){ //if depth_value in range
- printf("Value in Range:\n");
- if(depth_value>=spectrum*1 && depth_value<=spectrum*2){printf("Red %d\n",depth_value);}
- else if(depth_value>=spectrum*2 && depth_value<=spectrum*3){printf("Oragnge %d\n",depth_value);}
- else if(depth_value>=spectrum*3 && depth_value<=spectrum*4){printf("yellow\n %d",depth_value);}
- else if(depth_value>=spectrum*4 && depth_value<=spectrum*5){printf("Green\n %d",depth_value);}
- else if(depth_value>=spectrum*5 && depth_value<=spectrum*6){printf("blue %d\n",depth_value);}
- else if(depth_value>=spectrum*6 && depth_value<=spectrum*7){printf("fuchia %d\n",depth_value);}
- else if(depth_value>=spectrum*7 && depth_value<=spectrum*8){printf("violet %d\n",depth_value);}
- }else {
- if(depth_value<minD || depth_value>maxD){printf("balck %d\n",depth_value);}
- }
- /*
- for (int i=minD; i<=maxD; i++){
- // Calculate the remainder when dividing N by 7
- int remainder = i % 7;
- // Subtract the remainder from N to make it evenly divisible by 7
- int result = i - remainder;
- printf(" %d divided by 7 remains:%d divisible by: %d\n",i,remainder, result);
- }
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement