C program to find prime numbers

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

C program to find prime numbers

Computer Science
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

#include #include void main() { int a,b; // initialization of variables clrscr(); // clear screen printf("Enter a Number:"); // display message scanf("%d",&a); //get value printf("\n\nPrime Factors of %d is: ",a); //display message for(b=2;b<=n;b++) //loop { // starting of for loop if(a%b==0) // if a/b and remainder is 0 then { printf("%d,",b); a=a/b; b--; if(a==1) break; } } getche(); }
Even though I don't understand this, I like it :P Great work! I appreciate it :)

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

\[\Huge \ddot \smile \]
its for finding prime number but in C
Yeah.. I can see that :)
I'm able to read the code a little. If(a%b == 0) means that the modulus of a and b is 0, correct?
More like \(a \text{ mod} b = 0\). == defines checking something.
yes but % = remainder operator
Yes, it's the same thing. :) http://www.cprogramming.com/tutorial/modulus.html
yap
http://pythonism.wordpress.com/2008/05/04/looking-at-prime-numbers-in-python/
python programming
So, wish me luck in Python!
Annas dada ki\[\Huge\mathsf{\text{Jai Ho!}} \]
lol
@annas is this the program to write the prime numbers or the program to find out the prime factors of a number..???
@anusha.p its for prime factors of a number thanks for figuring that out :)
u didn't declare n annas....aslo..u didn't initialize n...
thank you @anusha.p my typo mistake i m sorry lemme correct it
first of all prime number program: #include #include void main() { int n, i = 3, count, c; printf("Enter the number of prime numbers required\n"); scanf("%d",&n); if ( n >= 1 ) { printf("First %d prime numbers are :\n",n); printf("2\n"); } for ( count = 2 ; count <= n ; count++ ) { for ( c = 2 ; c <= i - 1 ; c++ ) { if ( i%c == 0 ) break; } if ( c == i ) { printf("%d\n",i); count++; } i++; } return 0; }
also... if(a%b==0) {........... ............. } if(a==1) { .......... ......... } getch(); }
#include #include void main() { int a,b; // initialization of variables clrscr(); // clear screen printf("Enter a Number:"); // display message scanf("%d",&a); //get value printf("\n\nPrime Factors of %d is: ",a); //display message for(b=2;b<=a;b++) //loop { // starting of for loop if(a%b==0) // if a/b and remainder is 0 then { printf("%d,",b); a=a/b; b--; if(a==1) break; } } getche(); } now its ok actually i wrote it in hurry so got some mistakes. and @anusha.p i m very much thankful to you for helping me out :) really appreciated it. @anusha.p brackets are rightly placed :)
no mention.......... yeah..braces are at their respective places only....lol.......sorry..
oh there is one more mistake : #include #include void main() { int a,b; // initialization of variables clrscr(); // clear screen printf("Enter a Number:"); // display message scanf("%d",&a); //get value printf("\n\nPrime Factors of %d is: ",a); //display message if(a==1){ break; } else{ for(b=2;b<=a;b++) //loop { // starting of for loop if(a%b==0) // if a/b and remainder is 0 then { printf("%d,",b); a=a/b; b--; } } } getche(); }
what i did is i put the if condition where the user gives value
thank you once again @anusha.p
getch() and getche() are used to get input from the keyboard in character but in getche() it will display character on screen too. here "e" stands for echo

Not the answer you are looking for?

Search for more explanations.

Ask your own question