C Program to Find Prime Number and Complex Number

How to write a C Program to Find Prime Number and Complex Number in C Programming Language ?

Solution:


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

int main()
{
    int x,i,brojac;
    scanf("%d",&x);
    brojac=0;
    for(i=1; i<=x; i++)
    {
        if(x%i==0) brojac++;
    }
    if(brojac==2)
    {
        printf("prime number");
    }
    else
        printf("a complex number");


    return 0;
}


Learn More :