C program to check prime numbers , C/C++ Programming

Assignment Help:

C Program to check PRIME NUMBERS

 

main()

{

          int i,k,r,flag;

          clrscr();

          printf("ENTER THE NO. TO CHECK IT IS PRIME OR NOT: ");

          scanf("%d",&k);

          for(i=2;i<=k/2;i++)

 

          {

                   r=k%i;

                   if(r==0)

                             flag=0;

                   else

                             flag=1;

          }

          if(flag==1)

                   printf("THIS IS A PRIME NO.");

          else

                   printf("THIS IS NOT A PRIME NO.");

          getch();

}

 

OUTPUT :

 ENTER NO: 10

IT IS NOT A PRIME NO.

 


Related Discussions:- C program to check prime numbers

Minimumshelf, At a shop of marbles, packs of marbles are prepared. Packets ...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

What is your reaction to following line of code? , Q-What is your reaction ...

Q-What is your reaction to following line of code?               delete this; A: This is not a good programming Practice. A good programmer will insist that you must absolute

C Program with android, Hello, I would like to know if you can help in C pr...

Hello, I would like to know if you can help in C programs that work on android.

Assignment, Ask question #MA company is rewriting its payroll system to mov...

Ask question #MA company is rewriting its payroll system to move it from an old mainframe to a distributed mini-computer/PC-based networked setup. No new functionality will be adde

Assignment, Classify computer systems according to capacity. How they are d...

Classify computer systems according to capacity. How they are different from computers according to the classification of technology. Provide comparative study also.

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Develop online slot video game for facebook, Develop Online Slot Video Game...

Develop Online Slot Video Game for Facebook Prepare an online slot video game for a Facebook promotion in order to draw new visits and Increase the number of "likes" of the Face

Define register simply with bit fields, Define register with bit fields? ...

Define register with bit fields? We could define register simply with bit fields: struct DISK_REGISTER { unsigned ready:1; unsigned error_occured:1; unsigned disk_spinni

Padovan string, padovan string program in java // aakash , suraj , p...

padovan string program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class PadovanString {     publ

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd