C Program To Find Prime Numbers From 1 To 300 using For Loop

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

Lets write a C program to print all the prime numbers from 1 to 300. (Hint: Use nested loops, break and continue).

Prime Number: is a natural number greater than 1, which has no positive divisors other than 1 and itself.

Note: Number 1 is neither prime nor composite number.

C Programming Interview / Viva Q&A List

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

can you provide algorithm and flowchart of this ques

GauravSharma-kdwc
Автор

Your result is showing 1 as a prime number.. How??

hirabiswas
Автор

The vedio in your channel is very nice and beautiful

EDUCATIONFORTODAY
Автор

an other way to write the programme for same output.
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
int main(){
int inputval, x, y, z;

printf("enter a digit");
scanf("%d", &inputval);


for (x=2; x<=inputval; x++){
for (y=x-1; y>0; y--){
z=x%y;
if (z==0 && y>1){
break;
}
else if (z==0 && y==1)
printf("%d\n", x);
}
}
return 0;
}

nakulgodara
Автор

sir why the prime = 0 is there in second loop and prime =1 in first for loop please explain

programmingdna
Автор

U r explains are good but, I want much more clarity.

muvvalaprasanthkumar
Автор

here why is num/2 in inner for loop, what is the purpose of it

chelsea
Автор

after breaking if(prime=0) how the prime= 1 works can u explain this please

programmingdna
Автор

How to find largest 9 digit prime number in c program

aarulive