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
Write the test cases for checking a variable having value in range -10.0 to +10.0?
what is recursion in C
How to compare array with pointer in c?
Are c and c++ the same?
Explain what is the use of a semicolon (;) at the end of every program statement?
What are the two types of structure?
What are the modifiers available in c programming language?
Define VARIABLE?
Why is void main used?
Can 'this' pointer by used in the constructor?
How do you print only part of a string?
Write a program to reverse a linked list in c.
What is default value of global variable in c?
What is a union?
Can we initialize extern variable in c?