List 100 prime numbers

broken image
broken image

Within this loop, another 'for' loop is used with the counter variable 'j' to iterate from 2 to 'i-1'. Next, the program uses a 'for' loop with the counter variable 'i' to iterate from 1 to the value of 'n'.

broken image

The program then prompts the user to enter a value using the 'printf' function and stores the value in the variable 'n' using the 'scanf' function. The variable 'prime' is used to store the number of times a number is divisible by any number other than 1 and itself, if a number is divisible by any number other than 1 and itself it means the number is not prime. The variable 'n' is used to store the value entered by the user, while 'i' and 'j' are used as loop counters in the program. Within the main function, the program declares four variables: 'i', 'j', 'n', and 'prime'. The program starts by including the conio.h library, which is not a standard library of C, it's a non-standard library and is used for console input/output. This program is written in the C programming language and is used to print all the prime numbers up to a given limit.

broken image

Printing Prime Numbers up to a Given Limit in C Programming

broken image