Write a program to read in a positive integer, Computer Engineering

Assignment Help:

Write a program to read in a positive integer and check whether it is prime or not?

/* Program to check whether a given number is prime or not*/]

# include

# include

void main()

{

int i=2,n,flag=1;

clrscr();

printf("\nEnter the number : ");

scanf("%d",&n);

while(i

{

if(n%i==0)

{

flag=0;

printf("\n%d is not a prime number",n);

break; /*takes control out of the while as soon as the numbers is fully divisible */

}

else i++;

}

 


Related Discussions:- Write a program to read in a positive integer

Syntax and semantics - first-order logic, Syntax and Semantics: Propos...

Syntax and Semantics: Propositional logic is prohibited in its expressiveness: so just to represent true and false facts for the world. By a type of extending propositional lo

Find fiber distributed data interconnect is an example of, FDDI (Fiber Dist...

FDDI (Fiber Distributed Data Interconnect) is an example of? Fiber Distributed Data Interconnect is an illustration of token ring.

What will occur when contents of register are shifter left, What will occur...

What will occur when contents of register are shifter left, right? This is well known that into left shift all bits will be shifted left and LSB will be appended along with 0 a

Explain the concept of top-down design for a program, Explain the concept o...

Explain the concept of top-down design for a program. Top down Design: A top-down approach is fundamentally breaking down a system to gain insight into its compositional s

Explain the program invisible registers, What are program invisible registe...

What are program invisible registers? Global and local descriptor tables are found in memory system. In order to specify and access the address of these tables, program invisi

What guarantees the integration of all application modules, What guarantees...

What guarantees the integration of all application modules? The R/3 basis system guarantees the integration of all application modules.  The R/3 basis s/w gives the run time e

Describe collective communications, Q. Collective Communications? A num...

Q. Collective Communications? A number of message-passing systems allow communication involving more than two processors. Such type of communication can be known as collective

What are the static and dynamic hazards in logic circuits, If for a short p...

If for a short period of time circuits goes to some dissimilar logic level then it is assumed to have then it is known as static hazard e.g. If the final logic value of output of a

fisherpersons are not over-fishing, Prepare the Relational Tables to signi...

Prepare the Relational Tables to signify the following situation, which is defined by means of text and an Entity Relationship Diagram. Note: Do not attempt to vary the ERD. Yo

Difference in natural frequency and resonant frequency, (a)  Explain in a f...

(a)  Explain in a few sentences the difference between a natural frequency and a resonant frequency.  Also clarify why for a specific system or component these frequencies may diff

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