So, open Codeblocks and start a new project. Select Files >> C/C++ Source>>File name with path>>and then click ok. This way create a new c programming project workspace.
Oh! I forgot to tell that if you do not have codeblocks or some other compilers for c, you can download CodeBlocks from the below link.
Download CodeBlocks
Now, just copy the below code and paste it in the codeblocks new project workspace.:
/*This program has been created, build, presented by, Mehbubul Hasan AL- Quvi. http://www.rokzzquvi.weebly.com*/
#include <stdio.h>
int main()
{
int num, i, z=0;
printf ("Enter a number: ");
scanf ("%d", &num);
for (i=3; i<=num/2; i=i+2)
{
if (num%i==0)
{
z=1;
}
}
if (num == 0)
{
printf ("\n%d is zero", num);
}
else if (num<2)
{
printf ("\n%d is not a prime number.", num);
}
else if (num==2)
{
printf ("\n%d is a prime number.", num);
}
else if (num%2 == 0)
{
printf ("\n%d is not a prime number.", num);
}
else if (z==0 && num!=1)
{
printf ("\n%d is a prime number.", num);
}
else
{
printf ("\n%d is not a prime number.", num);
}
return 0;
}
/*Sample of Mehbubul Hasan AL- Quvi. All rights reserved to Red Cross*/
/*http://www.rokzzquvi.weebly.com*/
The program will run and it must work fine without any errors.
However, if you find any bug or errors, please let me know that through your comments.