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 is basic authentication worked, How is basic authentication worked? ...

How is basic authentication worked? When an exact resource has been protected using fundamental authentication, Apache sends a 401 Authentication needed header along with the r

What are the limitations of a cyclotron, Q. What are the limitations of a c...

Q. What are the limitations of a cyclotron? Limitations (i) Maintaining a consistent magnetic field over a large area of the Dees is difficult. (ii) At high rapidity

No-signs to the write statement, Suppressing the number signs (+/-) is carr...

Suppressing the number signs (+/-) is carried out using the addition NO-SIGNS to the Write statement.  Statement is wrong.

Address - operand data types, Q. Address - operand data types? A...

Q. Address - operand data types? Addresses : Operands residing in memory are specified by their memory address while operands residing in registers are specified by a re

What are the basic components of dialog program, What are the basic compone...

What are the basic components of dialog program? Screens (Dynpros) Every dialog in an SAP system is controlled by dynpros. A dynpros having of a screen And its flow log

Computer graphics, what isAdvantages of scan line algorithm, Computer Graph...

what isAdvantages of scan line algorithm, Computer Graphics?

Explain characteristics in java for e-commerce applications, Explain the ch...

Explain the characteristics and utilities available into java that makes it appropriate for developing e-commerce applications. Following are the characteristics and utilities

Modified digital clock, can you deign the schematic of a modified digital c...

can you deign the schematic of a modified digital clock at the gate as well as the IC level and then construct the circuit, lab spec and industral spec?

What are the pros and cons of on-line documentation, Question 1: You wa...

Question 1: You want to perform the task of setting an alarm on your mobile phone. You can assume that the alarm option is accessible from the main menu of your phone. (a) P

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