w3resource
C Programming Exercises

C Exercises: Test if a non-negative number is a multiple of 13 or it is one more than a multiple of 13

C-programming basic algorithm: Exercise-19 with Solution

Write a C program to test if a non-negative number is a multiple of 13 or it is one more than a multiple of 13.

C Code:

#include <stdio.h>
#include <stdlib.h>

int main(void){
    printf("%d",test(13));
    printf("\n%d",test(14));
    printf("\n%d",test(27));
    printf("\n%d",test(41));
    }   
    
    int test(int n)
         {
           return n % 13 == 0 || n % 13 == 1;
        }

Sample Output:

1
1
1
0

Flowchart:

C Programming Algorithm Flowchart: Test if a non-negative number is a multiple of 13 or it is one more than a multiple of 13

Solution

Contribute your code and comments through Disqus.

Previous: Write a C program that accept two integers and return true if either one is 5 or their sum or difference is 5.
Next: Write a C program to check if a given non-negative given number is a multiple of 3 or 7, but not both.