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

How to load dos from hard disk, Q. How to Load DOS from Hard Disk? To L...

Q. How to Load DOS from Hard Disk? To Load DOS from the Hard Disk of your computer, follow these steps: 1. Turn on the power ON/OFF switch of the CPU unit of your PC the pow

How the information can be stored, In a RAM, information can be stored ? A...

In a RAM, information can be stored ? Ans. RAM is used by the user, number of times.

Example of asymptotic notations, Q. Example of asymptotic notations? Th...

Q. Example of asymptotic notations? The function f (n) belongs to the set  (g(n)) if there exists positive constants c such that for satisfactorily large values of n we have 0

Define interrupt processing, Q. Define Interrupt Processing? On complet...

Q. Define Interrupt Processing? On completion of execution of an instruction machine checks whether there is any pending interrupt request for interrupts which are enabled. If

Define virtual memory, Normal 0 false false false EN-IN...

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

Java, mine sweeper algorithm.

mine sweeper algorithm.

Components of information super highway infrastructure, Explain the compone...

Explain the components of Information Super Highway Infrastructure. The Information Superhighway is more than the Internet. It is a sequence of components, having the collectio

Multi tasking environment, Q. Explain about Multi tasking environment? ...

Q. Explain about Multi tasking environment? Multi tasking uses parallelism by: 1) Pipelining functional units are pipe line mutually 2) Simultaneously employing multiple

Which 802 standard provides for a collision free protocol, Which 802 standa...

Which 802 standard provides for a collision free protocol? 802.5 standard gives for a collision free protocol.

Write a perl script, Write a PERL script which takes a file named input.txt...

Write a PERL script which takes a file named input.txt as an input and processes it. The input file has the following format: firstname lastname: pass/fail score%. A sample input f

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