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

Define the translator which perform macro expansion, Define the translator ...

Define the translator which perform macro expansion is known as a                      Macro pre-processor is the translator which perform macro expansion

Events by which we can program "help texts", What are the events by which w...

What are the events by which we can program "help texts" and display "possible value lists"? -PROCESS ON HELP-REQUEST (POH). -PROCESS ON VALUE-REQUEST (POV).

Explain r-2r ladder d/a converter, Explain R-2R ladder D/A converter. A...

Explain R-2R ladder D/A converter. Ans. R-2R ladder D/A converter: An R-2R ladder D/A converter is shown in Fig.(a). It uses resistors of only two values R and 2R. The inp

Illustrate layout of magnetic disk, Q. Illustrate Layout of Magnetic Disk? ...

Q. Illustrate Layout of Magnetic Disk? Head is a relatively small device capable of reading from or writing to a part of platter rotating beneath it. This gives rise to organiz

Find out the 2's complement of 1101110, The 2's complement of the number 11...

The 2's complement of the number 1101110 is ? Ans. 1's complement of 1101110 is = 0010001 ans hence 2's complement of 1101110 is = 0010001 + 1 = 0010010.

Handling interrupts - computer architecture, Handling Interrupts: Pre...

Handling Interrupts: Precise interrupts (sequential semantics) Complete instructions before the offending instructions o   Force trap instruction into IF o

Register-to-register architecture, Register-to-Register Architecture : In t...

Register-to-Register Architecture : In this organization, results and operands are accessed not directly from the main memory by the scalar or vector registers. The vectors which a

Purpose of storage - computer architecture, Purpose of storage: Several...

Purpose of storage: Several different forms of storage, based on different natural phenomena, have been invented.  So far, no practical universal storage medium persists, and a

What is artificial intelligence recognition, There are two goals to AI; the...

There are two goals to AI; the major one is to produce an artificial system that is about as good as or good than a human being at dealing with the actual world. The second goal is

Illustrate the advantages of encapsulation, Advantages of Encapsulation ...

Advantages of Encapsulation You can also delay the resolution of the details until after the design.  You can keep your code modular.

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