write the program for prime numbers?

Answer Posted / sudesh kumar

#include<iostream.h>
#include<conio.h>
void main()
{
int no,i,r,p=1;
cout<<"enter a no";
cin>>no;
for(i=2;i<no;i++)
{
if(r==no%i)
{
p=0;
break;
}
}
if(p==0)
{
cout<<"the prime no";
}
else
{
cout<<"the no is note prime";
}
getch();
}

Is This Answer Correct ?    13 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I determine whether a machines byte order is big-endian or little-endian?

617


Differentiate between ordinary variable and pointer in c.

615


which type of aspect you want from the student.

1701


What is the scope of local variable in c?

578


What is static memory allocation? Explain

632






Is null a keyword in c?

732


What is double pointer?

558


FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

621


Explain what is a program flowchart and explain how does it help in writing a program?

648


Where in memory are my variables stored?

635


What is volatile variable in c with example?

585


What are the three constants used in c?

545


Can two or more operators such as and be combined in a single line of program code?

808


What is main () in c language?

592


Can you subtract pointers from each other? Why would you?

558