Like this, 23 is also not divisible by anything except 1 and The question is, write a program in C to print all prime number from 1 to Here is its answer:. As the program was written under Code::Blocks IDE, therefore after successful build and run, here is the sample run:. Now let's modify the above program with adding some extra features. Here in this program we've added to allow user to provide the range under which all the prime numbers gets printed.
That is, this program will ask from the user to enter starting number say 10 and ending number say to print all the prime numbers present in between these two numbers say 10 and as shown in the program given below:.
Find roots of a quadratic equation. Print Pyramids and Patterns. Check prime number. Print the Fibonacci series. Reference Materials string. Start Learning C. Explore C Examples. C Examples Print Pyramids and Patterns. Make a Simple Calculator Using switch Display Factors of a Number.
Check Armstrong Number. Check Whether a Number is Prime or Not. Check Whether a Number is Palindrome or Not. Types of User-defined Functions in C Programming. C Control Flow Examples. C Program to Check Whether a Number is Prime or Not In this example, you will learn to check whether an integer entered by the user is a prime number or not.
To understand this example, you should have the knowledge of the following C programming topics: C if Share on:. Did you find this article helpful?
0コメント