DO NOT MISS

Ads

Sunday, 31 July 2016

Program 12 Using While loop



The number which has only two factors then the number is called as a Prime number.
(or)
A prime number is a whole number greater than 1, whose only two whole-number factors are 1 and itself. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29.

#include<stdio.h>
#include<conio.h>

void main()

       {

               int n,i,fc=0;
               clrscr();

               printf("enter a number:");
               scanf("%d",&n);

               i=1;
               
while(i<=n)
                      {
                           if(n%i==0)
                           fc++;
                           i++;
                      }

              if(fc==2)
              printf("the number is prime number:");
              else
              printf("the number is not prime number:");
              getch();

      }


Output:-


______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________


Greataims

 
Copyright © 2016 Computersadda. Designed by @ Computersadda Team - Published By Greataims