write the program for prime numbers?

Answer Posted / sachin 12

#include<stdio.h>
#include<conio.h>
void main()
{
int num,i=2,f=0,j;
printf("\n enter any number");
scanf("%d",&num);
a=num;
while(i<num)
{
if(num%i==0)
{
f=1
break;
}
i++;
}
if(f==i)
{
printf("\n the number is not prime");
}
else
{
printf(""\n the number is prime");
}
getch();
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different types of C instructions?

681


How can you tell whether a program was compiled using c versus c++?

622


Explain what are compound statements?

608


What is #pragma statements?

593


Why is it important to memset a variable, immediately after allocating memory to it ?

1557






What is nested structure in c?

616


what are bit fields? What is the use of bit fields in a structure declaration?

1501


Why c is called free form language?

575


What is anagram in c?

521


What is the use of clrscr?

600


Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.

2654


How many loops are there in c?

584


How does pointer work in c?

623


How can my program discover the complete pathname to the executable from which it was invoked?

663


Define Spanning-Tree Protocol (STP)

648