C Program To Find Prime Numbers Between Range, using For Loop

preview_player
Показать описание

Lets write a C program to find and print/display all the prime numbers between 2 integer values input by the user, using nested for loop.

Prime Number: Any natural number which is greater than 1 and has only two factors i.e., 1 and the number itself is called a prime number.

C Programming Interview / Viva Q&A List

C Programming: Beginner To Advance To Expert
Рекомендации по теме
Комментарии
Автор

after getting a lot of critical codes I found your this video. It really helped me a lot. thank you so much!

muhammedafnan
Автор

Helped me a lot ty bro for these videos❤

nischay
Автор

Can you explain a program to print prime number ina given range which last digit is 7

yasodhadevim
Автор

/* Write a program in C to find prime number within a range.
Input number for ending range: 100
The prime numbers between 1 and 100 are:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73
79 83 89 97
The total number of prime numbers between 1 to 100 is: 25 */

#include<stdio.h>
#include<conio.h>
int main()
{
int s, e, n, i, prime;
printf("Enter starting number = ");
scanf("%d", &n);
s=n;
printf("Enter ending number = ");
scanf("%d", &e);
printf("\n");
printf("The prime number between %d and %d = ", n, e);
for(i=s;i<=e;i++)
{
if(i==1)
i++;
prime=1;
for(n=2;n<i;n++)
{
if(i%n==0)
{
prime=0;
break;
}
}
if(prime)
printf("\t%d", i);
}
printf("\n");
return 0;
getch();
}
yes i got it 🙂 (thanks)

interestingtechnology
Автор

Oh bro thaank you so much! It was helped me much

atpTUBE
Автор

If num is 9 then num%count ==1, then it prints 9 too right??

samshaikh