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

Explain how does free() know explain how much memory to release?

575


Are c and c++ the same?

627


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

649


What is d scanf?

595


Are pointers integer?

550






What is a string?

666


What 'lex' does?

717


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

1738


Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.

1570


What is identifier in c?

543


Why isn't any of this standardized in c? Any real program has to do some of these things.

623


What does sizeof function do?

612


What is the difference between array and pointer in c?

579


What does c mean before a date?

592


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

15048