C Program To Find Prime Numbers From 1 To 300 using For Loop
ฝัง
- เผยแพร่เมื่อ 30 ก.ย. 2024
- technotip.com/7...
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
technotip.com/6...
C Programming: Beginner To Advance To Expert
technotip.com/6...
can you provide algorithm and flowchart of this ques
U should try to explain better
Your result is showing 1 as a prime number.. How??
use i=2
1 is not a prime number bro
The vedio in your channel is very nice and beautiful
wait, 1 isnt a prime number
sir why the prime = 0 is there in second loop and prime =1 in first for loop please explain
I'm initializing prime to 1 before second for loop starts. After the second for loop execution completes I check if prime is still 1. If so, then the number is PRIME orelse it's NOT PRIME.
an other way to write the programme for same output.
#include
#include
#include
int main(){
int inputval, x ,y ,z;
printf("enter a digit");
scanf("%d",&inputval);
for (x=2; x0; y--){
z=x%y;
if (z==0 && y>1){
break;
}
else if (z==0 && y==1)
printf("%d
",x);
}
}
return 0;
}
Thank you very much. 👍👍🔝🔝
Thanks
Superb explanation bro..
U r explains are good but , I want much more clarity.
Bhai please ek bar me sanjaya ka
here why is num/2 in inner for loop, what is the purpose of it
I=2 kyu liya 2 nd for loop me
after breaking if(prime=0) how the prime= 1 works can u explain this please
You can find the complete source code and explanation on our website. Kindly visit the link present in the description section of above video. Thank you 🙏
It basically means that when prime=0 then the complier would understand that it is not a prime numbers and when prime is prime which means prime=1 we specify the compiler that the number is prime
ok thanks
@@Sake679
Thank u so much sir
How to find largest 9 digit prime number in c program