write the program for prime numbers?

Answer Posted / oza priyanka

#include<stdio.h>
void main()
{
int num,i,cnt;
clrscr();
printf("\n\nEnter the number = ");
scanf("%d",&num);
for(i=2,cnt=0;i<num;i++)
{
if(num%i==0)
cnt=1;
}
if(cnt==0)
printf("\n\nprime number");
else
printf("\n\n not a prime number");
getch();
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between functions abs() and fabs()?

652


Is there a way to switch on strings?

623


What is extern storage class in c?

517


int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer

662


What are the types of i/o functions?

685






why do some people write if(0 == x) instead of if(x == 0)?

657


What is a program?

669


Explain how can I write functions that take a variable number of arguments?

619


What is the size of array float a(10)?

659


What is call by value in c?

563


What is the c value paradox and how is it explained?

580


Why is c so powerful?

691


Explain what is the general form of a c program?

627


cavium networks written test pattern ..

3600


What is type qualifiers?

668