write the program for prime numbers?

Answer Posted / paul

#include <stdio.h>
#include<stdlib.h>

#define TRUE 1
#define FALSE 0

int main()
{
int i,x,prime = TRUE;
printf(".:Modified Prime Program:.\n\n");
printf("Enter a number: ");
scanf("%d",&x);
printf("\nNUMBER\t REMARKS\n");
do
{
for(i=2;i<x;i++)
if(x%i==0)
{
prime=FALSE;
break;
}
if (prime=1 && (!(i<=x/2)))
printf("%d\t PRIME\n",x);
else
printf("%d\t COMPOSITE\n",x);
}
while (x-=1);
system ("pause");
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write the test cases for checking a variable having value in range -10.0 to +10.0?

1822


what is recursion in C

619


How to compare array with pointer in c?

627


Are c and c++ the same?

629


Explain what is the use of a semicolon (;) at the end of every program statement?

740






What are the two types of structure?

581


What are the modifiers available in c programming language?

745


Define VARIABLE?

692


Why is void main used?

625


Can 'this' pointer by used in the constructor?

617


How do you print only part of a string?

620


Write a program to reverse a linked list in c.

649


What is default value of global variable in c?

564


What is a union?

613


Can we initialize extern variable in c?

639