answersLogoWhite

0

#include

#include

void

main()

int prime(int n)

{

int i, j=n/2;

clrscr();

for(i=2; i<=j; i++)

{

if(n%j==0)

return 0;

}

return 1;

}

void

main()

{

int a,b,i;

clrscr();

printf("\n enter the twin prime numbers");

scanf("d",&a,&b);

printf("\n twin prime within this range \n");

if(a%2!==0)

i=a+1;

else;

i=a;

while(i+2<=b)

{

if(prime (i) &&prime(i+2) )

printf("\n%d\t%d",i,i+2);

i+1=2;

}

getch();

}

#include

#include

void main()

{

Int i, j, C;

printf("Enter the no");

Scanf("%d", &n);

for(j=2; j

{

If(n%j==0)

{

c++;

}

}

if(c==0)

{

printf(" Entered no is prime no");

}

getch();

}

Code example:

#include

#include

#include

void main()

{

int i,j;

clrscr();

for(i=3;i<=1000;i++)

{

for(j=2;j<=i;j++)

{

if(i%j==0)

break;

}

if(i==j)

cout<

}

getch(); // this is the easiest method for finding prime nos made by Taabi

}

B:

To write the c version: i.e not C++, you write: A: /****************************** * THIS IS THE EASIEST * METHOD OF GENERATING * PRIME NUMBERS USING C * MADE BY: githambo@gmail.com

*******************************/ #include #include int main() { int i,j,h,n; printf("Start:\a\n"); scanf("%d",&n); printf("End?\n\a"); scanf("%d",&h); for(in;i<h;i++) { for(j2;j<i;j++) { if(i%j0) break; }if(ij) printf("%d\t",j); } return 0; }

User Avatar

Wiki User

9y ago

What else can I help you with?

Continue Learning about Engineering

Write a c program to generate all prime numbers in the given range?

look man that would take alot &gt;&gt;&gt; Ill give you the way =============================================================================== this answer i write it now on net ! i read about that befor in it uni where i study i will chick out the answer and re write it best wishes 2024


What BASIC program can compute and display all prime numbers from 1 to 40?

PRINT 2,3,5,7,11,13,17,19,23,29,31,37


Write a c program to find out the prime numbers between 1 to 500?

Here is a simple program to generate prime numbers upto a given specific number /*Prime No. from 1 to 50*/ /*By-Himanshu Rathee*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int i,j,n; clrscr(); printf(" Enter the number upto which we have to find the prime number: "); scanf("%d",&amp;n); printf("\n"); for(i=2;i&lt;=n;i++) { for(j=2;j&lt;=i-1;j++) if(i%j==0) break; /*Number is divisble by some other number. So break out*/ if(i==j) printf("\t%d",i); /*Number was divisible by itself (that is, i was same as j)*/ } /*Continue loop upto nth number*/ getch(); }


How do you write a program in lisp to find if a number is prime or not?

(defun prime (num) (if (&lt; 2 num) (do ((dividend 2 (1 + dividend)) (chk-to (sqrt num))) ((equal (rem num dividend) 0)) (when (&lt;= chk-to dividend) (return t))) t))


Write a program in c to print first ten prime numbers?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; int main() { int a; printf("the no from 1 to 10 are:\n"); for(a=1;a&lt;=10;a++) printf("%d\n", a); getch(); }

Related Questions

What is the greatest six digit number you can write if each digit must be different and no digit may be prime?

Its impossible, there are only 5 single digit numbers that are not prime


How do you write a VBnet program to find the prime numbers between 100 to 200?

VBnet program to find the prime numbers between 100 to 200?


How do you write a program in objective c numbers 1-100 prime numbers?

fdsgfhgdfhgdf


How many two digit prime numbers are there?

There are 21 two-digit prime numbers.


Write a C program to find the sum of all prime numbers?

Since there is an infinite set of prime numbers the answer would be infinity.


Write a c program to print prime numbers from 1 to 10000 that has an unit digit which is multiple of 3?

This is a homework question and does not deserve an answer because you will learn nothing other than being lazy.


How many three digit numbers have odd prime number as 1st digit A prime number as 2nd digit and an odd number as 3rd digit?

There are 17 such numbers.


What are all of the one-digit prime numbers?

2, 3, 5, and 7 are the only one-digit prime numbers.


What is the largest two-digit number that is prime and has prime numbers for both of its digits?

73 is the largest two-digit number that is prime and has prime numbers for both of its digits.


How many 2 digit prime numbers are there?

There are 21 two-digit prime numbers. The first two-digit prime number is 11, and the last two-digit prime number is 97. Prime numbers are numbers greater than 1 that are only divisible by 1 and themselves.


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


How many two digit prime numbers have a units digit of 7 and what are the prime numbers?

17, 37, 47, 67, 97