no arguments passed and no return value

Solutions on MaxInterview for no arguments passed and no return value by the best coders in the world

showing results for - "no arguments passed and no return value"
Yusuf
26 Mar 2018
1#include <stdio.h>
2
3void checkPrimeNumber();
4
5int main()
6{
7    checkPrimeNumber();    // argument is not passed
8    return 0;
9}
10
11// return type is void meaning doesn't return any value
12void checkPrimeNumber()
13{
14    int n, i, flag = 0;
15
16    printf("Enter a positive integer: ");
17    scanf("%d",&n);
18
19    for(i=2; i <= n/2; ++i)
20    {
21        if(n%i == 0)
22        {
23            flag = 1;
24        }
25    }
26    if (flag == 1)
27        printf("%d is not a prime number.", n);
28    else
29        printf("%d is a prime number.", n);
30}
31