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
What is the advantage of using #define to declare a constant?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
What are examples of structures?
Can 'this' pointer by used in the constructor?
if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above
Explain function?
What is variable initialization and why is it important?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
Why use int main instead of void main?
Write a C program to count the number of email on text
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
Find MAXIMUM of three distinct integers using a single C statement
What is the use of structure padding in c?
I came across some code that puts a (void) cast before each call to printf. Why?
Differentiate Source Codes from Object Codes