Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is the advantage of using #define to declare a constant?

1035


Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

1019


What are examples of structures?

1020


Can 'this' pointer by used in the constructor?

1040


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

1107


Explain function?

1033


What is variable initialization and why is it important?

1158


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

2574


Why use int main instead of void main?

1066


Write a C program to count the number of email on text

1849


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.

15923


Find MAXIMUM of three distinct integers using a single C statement

1005


What is the use of structure padding in c?

1008


I came across some code that puts a (void) cast before each call to printf. Why?

1148


Differentiate Source Codes from Object Codes

1473