check whether a no is prime or not.

Answer Posted / rama

#include<stdio.h>
main()
{
int n,i,r;
clrscr();
printf("Enter the positive integer value");
scanf("%d",&n)
i=2;
step1:
if(i<=sqrt(n))
{
r=n%i;
if(r==0)
{
printf("%d is not a prime",n);
goto end;
}
}
else
{
i++;
goto step1;
}
printf("%d is prime number",n);
end:
printf(" ");
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c++ awesome?

566


What is data structure in c++?

647


Why do we need runtime polymorphism in c++?

553


What does it mean to declare a member variable as static?

608


what are the events occur in intr activated on interrupt vector table

1176






What are special characters c++?

562


What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator?

630


Can we inherit constructor in c++?

582


What are the different types of polymorphism in c++?

583


What is the C-style character string?

600


What are disadvantages of pointers?

561


What is the hardest coding language to learn?

596


What is a c++ object?

613


Is c++ an oop?

583


What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal

693