..

FreePrograms

 

  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

FREE C PROGRAMS 

What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming Data Structures in C C interview Questions

C programming Tutorial : Free C Programs, C Programs Download

Prime Number C program

#include<conio.h>//header file
#include<stdio.h>//header file
void main() //starting of the main() function
{
int i,flag=0,a;//declaration of the variables
clrscr();
printf("Test whether a given no. is prime or not");
printf("\n\n\n\t\t------------INPUT-------------");
printf("\n\nenter a no. to be checked prime or not");//taking input from the user
scanf("%d",&a);
for(i=2;i<a;i++)
{
if(a%i==0)
{
flag=1;
break;
}
}
printf("\n\n\n\t\t------------OUTPUT------------");
if(flag==0)
printf("\n\nit is a prime no."); //printing output
else
printf("\n\nit is not a prime no."); //printing output
getch();

}

 

COPYRIGHT 2009 ALL RIGHTS RESERVED FREECPROGRAMS.COM