Write a program to print the prime numbers between 1 and 100
C Source code program to print all numbers between 1 and 100. This program can be altered to print all prime numbers between a range given by user. A prime number is one which is only dividable by 1 or by the the number itself. It should not be dividable by any other numbers. is_prime() is the core routine to check if number is prime or not. It starts from 2 till (number - 1) to check if the number is dividable. If divisible then remainder will be zero and prime check should fail else it will continue till (number - 1). We have a main loop to take care the entire range. This loop start from 1 till 100. This upper range can be changed by taking input from user. Main loop calls is_prime() function and passes the number as the argument and checks the return value. If it returns true the it prints the number can continue to the next number. Main loop should list all prime number as it completes its entire range.
Find More from our code collection
Armstrong number, binary number to a decimal number, bubble sort, decimal number to binary number, factorial of the given number factors, fibonacci numbers, HCF and LCM, matrix, mergesort, salary of the employee. palindrome, quadratic equation, star patterns, series etc. and much more...
Return to Example Source Code
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Free alt softwares