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

What is the dissimilarity between dynamic strain aging, Q. What is the diss...

Q. What is the dissimilarity between dynamic strain aging and strain aging? Answer:- Strain aging could be explains as "normal wear and tear" or the fatigue that is experi

Determine about the virtual private networks, Virtual Private Networks (VPN...

Virtual Private Networks (VPN) In order to encrypt/decrypt all the communication network traffic that passes through the Internet or Intranet, a VPN uses software or hardware.

Single instruction and multiple data stream (simd), Single Instruction and ...

Single Instruction and Multiple Data stream (SIMD) In this organisation, multiple processing elements are working under the control of a one control unit. It has multiple data

Stack and queue, Describe queue? Ans:  It is a type of data structure ...

Describe queue? Ans:  It is a type of data structure in which the data are stored in and retrieved on a First in first out (FIFO) basis. It grows in the direction of increasin

Diiferentiate between ROM and PROM, Diiference between ROM and PROM. R...

Diiference between ROM and PROM. ROM: It also called Read Only Memory is a Permanent Memory. The data is permanently stored and cannot be changed in Permanent ROM. This can o

Why spc is used, SPC is used for (A)  Carrying Exchange Control Functi...

SPC is used for (A)  Carrying Exchange Control Functions (B)  Carrying Subscriber Control Functions (C)  Exchange Hardware (D)  Signalling Purpose Ans:

General registers in a processor, In this segment, we will give very brief ...

In this segment, we will give very brief details of registers of a RISC system known as MIPS. MIPS is a register-to-register or load/store architecture and employs three address

Crafting an isa - computer architecture, Crafting an ISA: We will l...

Crafting an ISA: We will look at some decisions facing an instruction set architect, and In the design of the MIPS instruction set how those decisions were made. MIPS

What is sensitivity list, What is sensitivity list? A list of signals w...

What is sensitivity list? A list of signals which trigger execution of the block when they change value. Sensitivity list  indicates that when a change occurs to any one of

Describe the uses of credit cards and smart cards, Credit cards and smart c...

Credit cards and smart cards Credit cards comprise a magnetic stripe on the back made up of iron-based particles in a plastic film. Stripe is split up into 3 tracks which a

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