﻿ C exercises: Compute the sum of the three given integers. However, if any of the values is in the range 10..20 inclusive then that value counts as 0, except 13 and 17 - w3resource # C Exercises: Compute the sum of the three given integers. However, if any of the values is in the range 10..20 inclusive then that value counts as 0, except 13 and 17

## C-programming basic algorithm: Exercise-31 with Solution

Write a C program to compute the sum of the three given integers. However, if any of the values is in the range 10..20 inclusive then that value counts as 0, except 13 and 17.

C Code:

``````#include <stdio.h>
#include <stdlib.h>
int main(void){
printf("%d",test(4, 5, 7));
printf("\n%d",test(7, 4, 12));
printf("\n%d",test(10, 13, 12));
printf("\n%d",test(13, 12, 18));
}
int test(int x, int y, int z)
{
return fix_num(x) + fix_num(y) + fix_num(z);
}
int fix_num(int n)
{
return (n < 13 && n > 9) || (n > 17 && n < 21) ? 0 : n;
}
``````

Sample Output:

```16
11
13
13
```

Pictorial Presentation: Flowchart: C Programming Code Editor:
{"ft_lang_label":"__label__en","ft_lang_prob":0.7487078,"math_prob":0.9910627,"size":1604,"snap":"2020-24-2020-29","text_gpt3_token_len":434,"char_repetition_ratio":0.11,"word_repetition_ratio":0.22222222,"special_character_ratio":0.30610973,"punctuation_ratio":0.1552795,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99797744,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,null,null,4,null,4,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-06-01T06:29:41Z\",\"WARC-Record-ID\":\"<urn:uuid:ee8fd199-bd89-4e2f-9f9c-efe95fd0eb25>\",\"Content-Length\":\"107557\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5630e382-3c79-4c2b-b3c7-a516242ca302>\",\"WARC-Concurrent-To\":\"<urn:uuid:10951fb3-8dde-4aa1-b351-c20365dce024>\",\"WARC-IP-Address\":\"104.26.15.93\",\"WARC-Target-URI\":\"https://www.w3resource.com/c-programming-exercises/basic-algo/c-programming-basic-algorithm-exercises-31.php\",\"WARC-Payload-Digest\":\"sha1:QAGTR2N2ZA2NKUKAPJXIRC4I5Z3KTKIV\",\"WARC-Block-Digest\":\"sha1:CQAOS7SXRPMIGM3HLTP7T3OAOAYXISJ3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347414057.54_warc_CC-MAIN-20200601040052-20200601070052-00269.warc.gz\"}"}