C Program to Find Prime Number

Sdílet
Vložit
  • čas přidán 5. 09. 2024
  • C Program to Check Whether a Number is Prime or not (Primality Test). This video will help you understand various methods of finding the primality of a given number
    This video is a part of this C Programming Practice Programs Playlist: • C Language Practice Pr...
    ►Checkout my English channel here: / programmingwithharry
    ►Click here to subscribe - / @codewithharry
    Best Hindi Videos For Learning Programming:
    ►Learn Python In One Video - • Python Tutorial In Hin...
    ►Python Complete Course In Hindi - • Python Tutorials For A...
    ►C Language Complete Course In Hindi -
    • C Language Tutorials I...
    ►JavaScript Complete Course In Hindi -
    • JavaScript Tutorials I...
    ►Learn JavaScript in One Video - • JavaScript Tutorial
    ►Learn PHP In One Video - • Learn Php In One Video...
    ►Django Complete Course In Hindi -
    • Python Django Tutorial...
    ►Machine Learning Using Python - • Machine Learning Tutor...
    ►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
    ►Advanced Python Tutorials - • Intermediate/Advanced ...
    ►Object Oriented Programming In Python - • Object Oriented Progra...
    ►Python Data Science and Big Data Tutorials - • Python Data Science an...
    Follow Me On Social Media
    ►Website (created using Flask) - www.codewithhar...
    ►Facebook - / codewithharry
    ►Instagram - / codewithharry
    ►Personal Facebook A/c - / geekyharis
    Twitter - / haris_is_here

Komentáře • 361

  • @CodeWithHarry
    @CodeWithHarry  Před 4 lety +67

    Thanks a lot for 500k Subscribers. Means a lot!
    Should I do Instagram live sometime?
    Instagram - instagram.com/codewithharry

  • @coder_boy
    @coder_boy Před rokem +9

    Harry bhaiya, in the for loop i*i

  • @mjofficial.07
    @mjofficial.07 Před 4 lety +37

    It will get error .eg if n=49
    It will check from 2 to 6 and becomes prime but its composite.
    Therefore code should be :
    for (int i=2;i*i

  • @saiakshagn3553
    @saiakshagn3553 Před rokem +6

    but , when we give 4 as input it is giving as prime number so i think in for loop we need to put i*i

  • @sushilkumaryadav1615
    @sushilkumaryadav1615 Před rokem +10

    Brother tooo much complexed video. Try to make it short and to the point, very disappointed.

  • @SandipBhattacharya
    @SandipBhattacharya Před rokem +4

    Thanks for this video.
    All you have to do to test whether a number is prime or not is to divide it successively by all numbers from 2 to n/2, not n. If the remainder of any of these divisions is zero, the number is not a prime. If none of the remainders results in 0, it’s a prime number. Hope it's clear.

    • @Sid-ot8dx
      @Sid-ot8dx Před rokem +2

      it helped

    • @ramanshukla8498
      @ramanshukla8498 Před rokem

      if number is 2 then its modulus will be 0. then it should show not prime. but 2 is prime number

    • @gitanshagarwal7597
      @gitanshagarwal7597 Před 9 měsíci

      @ramanshukla8498 ​No it would be a prime number as the loop will only run if (i*i)

  • @chaitanyakadam5739
    @chaitanyakadam5739 Před 4 lety +21

    can you make the video on software engineer/ agile development plzzzz you explain good ❤️❤️❤️❤️

  • @AdarshSingh-cb5yf
    @AdarshSingh-cb5yf Před 4 lety +4

    7 th comment ...
    Aap ke es student ka......
    (You are the best forever )...
    You are my gurudev..😍😍😍😍😍❤️❤️❤️❤️❤️❤️

  • @shubhchaudhari7847
    @shubhchaudhari7847 Před 4 lety +1

    5 lakh Congratulations Harry Bhai..❤️💯....Please Ab tak ki journey pe Ek Video Banta hai...Us Video se hume Bohot Inspiration Milegi❤️❤️❤️

  • @ayushchoudhary3484
    @ayushchoudhary3484 Před 4 lety +2

    Jald hi sir aapka Chanel 1m pe aa jaayengi....Avi underrated Chanel hai ye bahut

  • @sudhangshudas3099
    @sudhangshudas3099 Před 3 lety

    Aapke videos dekh kar hi time complexity ki importance pata chali hai. Pure graduation aur post graduation me teachers ka time complexity padane ka motive ek hi tha ki, examiner ke samne zalil na hona pade.

  • @akshaykothari1929
    @akshaykothari1929 Před 4 lety +31

    Hi Harry, I think there is a bug in this program. I checked this code for the number 4 and it says it is prime. In the for loop, the condition should be changed to i * i

    • @vishwabhatt20
      @vishwabhatt20 Před 4 lety +5

      yes, I too checked and then corrected my mistake and wrote...i*i

    • @silentmahi3030
      @silentmahi3030 Před rokem +1

      yess

    • @priyanshuworld
      @priyanshuworld Před rokem

      What happen if we do I think it will resolve the problem i*i

    • @mohit8363
      @mohit8363 Před 11 měsíci +1

      Google ka copy paste program hh iska practical program sourab Shukla ka acha hh

    • @_lonely7
      @_lonely7 Před 10 měsíci +1

      Thanks bro, I was looking for this solution in comments 😄

  • @harshitachaurasia1246
    @harshitachaurasia1246 Před 4 lety +2

    okay..ye smjh me aa gya root n wala concept ..!

    • @Anixmusics
      @Anixmusics Před 3 lety

      yaah u r absolutely correct 😋

  • @imtiyazshaikh6185
    @imtiyazshaikh6185 Před 3 lety +2

    Best explanation on prime numbers💯💯

  • @amanpatel3841
    @amanpatel3841 Před 4 lety +3

    You teaches us a lot Harry bhaiya. Thank you for everything.

  • @codewithharryfanchannel559

    You are superb. Congrats for half million subscribers.

  • @sakshamdwivedi4273
    @sakshamdwivedi4273 Před 4 lety +8

    question - Who is the best tutor in youtube ?
    answer - 1) code with harry 2)Gfx mentor

  • @arunangshubiswas1381
    @arunangshubiswas1381 Před 4 lety +3

    Thank you Sir. Your efforts are very high I am sure that if any one follow this series will definitely love to learn C

  • @wahidali6023
    @wahidali6023 Před 4 lety

    Harry bhai kamal ho yaar bhagwan apko lambi umar,seht ,tandursti de or puri life apki khushiyo se bhari rhe jeevan me apko bhut safalta mile esi me kamna karta hun ap jo kr rhe ho bas krte ho ak na ak din ap bhut age jaoge ...thank you so much bro apke duara koi kuch kr jayega kuch ban jayega ....

  • @racharlashweta7075
    @racharlashweta7075 Před 4 lety +4

    Congratulations for 500k!

  • @aadityadabli
    @aadityadabli Před 4 lety +1

    Congratulations for 5 lakh subscribers🔥🔥🔥🔥!!!!!

  • @masterhashir6152
    @masterhashir6152 Před 4 lety +1

    Congratulations!!!! For 500k subscribers!!!! AB TO PARTY BANTI HAI BOSSS!!!!!😆😆

  • @oyepuru
    @oyepuru Před 4 lety +1

    Harry Bhai Answer Please Brother
    Bro Please Make A Video On Competitive Programing How To Start And Can I Use Python For Competitive Programing
    Or Like People Say choose C++ so can i use c++ only for Competitive coding and python for Devlopment
    Pleass answer kroo
    I know both saare comments hai but ans kro ✌️✌️✌️✌️✌️✌️
    Love you brother and thanks for giving free education

  • @viveksharmamca19a39
    @viveksharmamca19a39 Před 4 lety +2

    Congratulations for 500k subscribers sir 😍❤️

  • @DevWithPriyank
    @DevWithPriyank Před 4 lety +2

    Bhai data structure implementation ki alag playlist bano

  • @harshitachaurasia1246
    @harshitachaurasia1246 Před 4 lety

    You r such a nice human...
    You added everyone's mention to your story..
    May God bless u always and you bless us with your amazing content

  • @ajithamin9196
    @ajithamin9196 Před 4 lety +2

    KEEP Doing Bro . Congrats on 500k

  • @shobhitkatiyar9224
    @shobhitkatiyar9224 Před 4 lety +1

    Bhaiya mind blowing concept hai....

  • @bhartiaggarwal6427
    @bhartiaggarwal6427 Před 3 lety +7

    The efforts you put into your work are genuinely appreciative 🙌 Learning programming had never been so easy before 😇Thanks alot🥰

  • @harshsaini1584
    @harshsaini1584 Před 2 lety

    Itne easy concept ko apne ,itna hardest kar diya ,ki ab data structure bhi easy lag raha hai ,iske aage

  • @CaptainJackSparrow123
    @CaptainJackSparrow123 Před 4 lety +1

    Harry bhai thanks for this course, this course really help me
    Those who agree hit the like button

  • @rajinderrandhawa7758
    @rajinderrandhawa7758 Před 3 lety +1

    Thanks a lot Harry ... Good explanation for a beginner to understand the concept.

  • @085_shahkalp8
    @085_shahkalp8 Před rokem

    thank you bhai , you have solved my problem of coding

  • @rohanraonallani561
    @rohanraonallani561 Před 4 lety +7

    I think adding a break statement inside if block would increase the time complexity and it would make the code more optimal

  • @QitmeerHandmade
    @QitmeerHandmade Před 4 měsíci +1

    Good explanation

  • @Armygirl-ir3wv
    @Armygirl-ir3wv Před 2 lety +1

    Thanks a lot sir🙏🙏 plz try to make video on program of armstrong number

  • @ManishSharma-fi2vr
    @ManishSharma-fi2vr Před 4 lety

    Sir, you tried your best to taught this program and it is understandable.

  • @divyasinghrajput4323
    @divyasinghrajput4323 Před 8 měsíci +1

    Mind blowing 😊

  • @sandhyayadav172
    @sandhyayadav172 Před 3 lety +1

    @codewithharry , do you have knowledge of Object*(objectstar)

  • @latasuthar7904
    @latasuthar7904 Před 2 lety

    Sir it was a bit complicated but.. by the end of the vedio the program was clear. Thank you sir😊

  • @HinduWaffenChief
    @HinduWaffenChief Před 4 lety

    Sir congratulations 1/2 million.... 1 million soon........

  • @teeshagoyal692
    @teeshagoyal692 Před 3 lety +3

    Sir, yahan for loop me condition me i*i

  • @Swapnil_Mehta
    @Swapnil_Mehta Před 4 lety +3

    import java.util.*;
    class prime
    {
    public static void main(String args [])
    {
    Scanner ob=new Scanner(System.in);
    int n =ob.nextInt();
    int count =0;
    int i;
    for(i=1;i

  • @royfamily9273
    @royfamily9273 Před 2 lety

    Thanks Harry Bhaiya

  • @tusharsharma2024
    @tusharsharma2024 Před 3 lety

    Nice explanation bhaiya....
    Get your logic is very convenient 👍👍

  • @sairamsingh78
    @sairamsingh78 Před 2 lety +4

    For better time optimization I think u can just break the loop once isPrime becomes 0.

    • @adityaram7408
      @adityaram7408 Před 2 lety +1

      yes

    • @adityaram7408
      @adityaram7408 Před 2 lety +1

      #include
      int main()
      {
      int n;
      printf("enter number : ");
      scanf("%d", &n);
      if (n >= 0)
      {
      for (int i = 2; i < n; i++)
      {
      if (n == 2)
      {
      break;
      }
      if (n % i == 0)
      {
      printf("not ");
      break;
      }
      }
      }
      printf("prime");
      return 0;
      }

  • @adityashrivastava9033
    @adityashrivastava9033 Před 4 lety

    Harry bhai I've watched your each and every video

  • @abhirajput1049
    @abhirajput1049 Před 10 měsíci

    Great video harry bhaii..full explanation given thankyouu so much

  • @arjungadani7320
    @arjungadani7320 Před 4 lety +8

    Request : Python OpenCV Module course

  • @zeeshannandi2604
    @zeeshannandi2604 Před 2 lety

    very smart way to test prime divisibiltiy , impressive !

  • @subhashthenua7404
    @subhashthenua7404 Před 2 lety

    Maza aya bhadiya best explained 👏

  • @thakurrishabsingh
    @thakurrishabsingh Před 4 lety +1

    Brother, aap aur aap k videos awsmmm..... 👏👏a big thumpsup 🖒🖒

  • @cube194
    @cube194 Před 4 lety +2

    Congrats for half million 👍👌

  • @hiphopm7069
    @hiphopm7069 Před 4 lety +1

    Sir suru se coading sikhaye na PLZZ sir

  • @srishtiiisingh6595
    @srishtiiisingh6595 Před 4 lety +1

    Sir I am 18, I am learning Python (with your vedios) but ,please will u explain what up next I have to learn

  • @48tejasgupta88
    @48tejasgupta88 Před 4 lety

    Thanks for learning such a easy way.

  • @aryasharma2357
    @aryasharma2357 Před 4 lety

    congratulation for 500k subscribers

  • @rudro314
    @rudro314 Před 4 lety

    Congrats 500k...awesome bro..
    Keep it up..please make a video on how to add google ad on blog and wordpress website..plszzz

  • @MananGandhi
    @MananGandhi Před 4 lety +1

    Congratulations on hitting 500K

  • @mraiofacts
    @mraiofacts Před rokem +1

    Thank you Harry sir🙏🙏

  • @animexpeace3493
    @animexpeace3493 Před rokem +1

    Bro
    I tried some different method to know whether it is prime or not
    #include
    void main()
    {
    int n,i,m=0;
    printf("enter the number n ");
    scanf("%d",&n);
    for(i=1;i

  • @achyutsrivastava8050
    @achyutsrivastava8050 Před 3 lety

    0:46 OneNote Mast hai Harry bhai

  • @Annurbd
    @Annurbd Před 4 lety +2

    Congregation. I AM From Bangladesh

  • @mohanraina2036
    @mohanraina2036 Před 4 lety +2

    This is so much easier in python

    • @Anixmusics
      @Anixmusics Před 3 lety

      o bhaii har language ka na koi na koi funstion hota hai nahi to aise hi nahi parae hai

    • @mohanraina2036
      @mohanraina2036 Před 3 lety +1

      @@Anixmusics brother sorry but i don't truly understand ur hindi.....but as far as i can tell that u r trying to say that for everything there is a function in all languages..........but brother i can easily make this or any other program without the use of a function or module 😉

    • @Anixmusics
      @Anixmusics Před 3 lety

      @@mohanraina2036 in which you in ???

    • @mohanraina2036
      @mohanraina2036 Před 3 lety

      @@Anixmusics 12th

    • @Anixmusics
      @Anixmusics Před 3 lety

      @@mohanraina2036 are you Indian or foreigner

  • @manavsingh3941
    @manavsingh3941 Před rokem +1

    Can someone tell in this -> if condition why we didn't wrote (isPrime==1)
    if(isPrime){
    printf("The number %d is a prime number
    ", num);
    }
    else{
    printf("The number %d is not a prime number
    ", num);
    }

  • @surbhipaliwal3576
    @surbhipaliwal3576 Před 4 lety

    Sir ap bhut shandar pdhate ho 😍😍😍😍😍

  • @prateekyadav1126
    @prateekyadav1126 Před 4 lety

    congrats harry bhai for 5 lakh subscribe.

  • @adityabhawsar3526
    @adityabhawsar3526 Před 2 lety

    All clear 🙂 thankyou sir

  • @ShivamGupta-ly3sn
    @ShivamGupta-ly3sn Před rokem

    23:08 min mai ek dam shi baat kahi h

  • @vickygupta8376
    @vickygupta8376 Před 4 lety

    Harry many video's are available for C programming......plz start video's series on Azure

  • @ambarsnehashishjha5742

    20:22 understood

  • @artforeveryone9651
    @artforeveryone9651 Před 4 lety +2

    Please make a C++ SFML tutorial please 🙏🤗🤗

  • @chitranshishrivastava6109

    Agr koi no. Jo underrood m h or uska is trike s ans n aye jese abhi btaya h to kya krenge sir??

  • @chaitanya6521
    @chaitanya6521 Před 4 lety +1

    Sir python handwritten notes banado please

  • @abhaykumawat195
    @abhaykumawat195 Před 2 lety

    In One note your pencil dot is too small it creates confusion where are you pointing.... Do something for it pleaseee 😐😁... No shikayat in your teaching.... Thanks for this good teaching 😊

  • @surajkumarsingh4857
    @surajkumarsingh4857 Před rokem

    Got it bhaiya 2 to root(n)

  • @user-kk3og2it7y
    @user-kk3og2it7y Před měsícem

    Thankyou...

  • @lightyagami6994
    @lightyagami6994 Před 10 měsíci

    20:15 I THINK ROOT N TAKH ISLIYE JANA HAI KYUNKI ATLEAST BAKHI INTEGERS SE NAHI AAAPATA DEMANDED PRODUCT TO JO JAHAN PE EK PERFECT INTEGER MILEGA JO BANATHI HAI EK WOH PRODUCT JO HUM DEKHNA CHAHTEY HAIN KYUN NA USI KO HI ROOT MARK KRKEY TAKH CHLNA.

  • @rudranshnemade6299
    @rudranshnemade6299 Před 2 lety

    20:00
    Harry Bhai Thoda thoda samjha par time ke sath pura samaj me aa jayega

  • @jeenas1567
    @jeenas1567 Před 3 lety +1

    Can null statement be used in this program for non-prime numbers?

  • @hi_chaudhary
    @hi_chaudhary Před 4 lety +3

    27 minutes video only for 1 program...
    Yes I know very well explained..
    But.. Why, why so long. 🙄😕

    • @CodeWithHarry
      @CodeWithHarry  Před 4 lety +6

      Because I have explained the mathematics underneath it! How to solve in O(n) then O(root n)

    • @hi_chaudhary
      @hi_chaudhary Před 4 lety

      @@CodeWithHarry yes sir i know very well explained... But shorter videos will be more beneficial.. Please try to make shot videos..
      And I like your videos.. I have learned python with your playlist... And now I am learning web development.
      Thanks sir🙏

  • @ramikaran4461
    @ramikaran4461 Před 4 lety

    Very good mouse writing
    Mere to pen se bhai nai aate acche writing
    But, very good explanation 🙂

  • @YTSHANKY
    @YTSHANKY Před 4 lety +1

    Please bring advanced c# course.. i am waiting for months now..

  • @cyberzentech2929
    @cyberzentech2929 Před 4 lety +4

    sir Python ka project lau please
    Jo ve python ka projects cha te ho to comment and like karo

    • @harshitachaurasia1246
      @harshitachaurasia1246 Před 4 lety

      python k projects unhone upload kre hue h channel pe

    • @cyberzentech2929
      @cyberzentech2929 Před 4 lety +1

      but i want more new project in python

    • @harshitachaurasia1246
      @harshitachaurasia1246 Před 4 lety

      @@cyberzentech2929 same 👍😁

    • @anshdholakia714
      @anshdholakia714 Před 4 lety

      @@harshitachaurasia1246 go to w3resources to get more exercises. the one Haris does is basic and some are advances, but the ones on w3recourse range from the beginner level to ultimate

    • @harshitachaurasia1246
      @harshitachaurasia1246 Před 4 lety

      @@anshdholakia714 ya thanks for the info i know this already 😀

  • @melodiousbeats8339
    @melodiousbeats8339 Před rokem

    thank you harry sir

  • @viveksharmamca19a39
    @viveksharmamca19a39 Před 4 lety

    Sir aap jo bhi notes de rahe hai yadi wo printable format (ebook text format) mai hota to print karwana aur bhi aasan hota ... Yadi aap chahe to hum thora bahut fees bhi de skte hai ... Jo ki ebook banwane mai lgega aapko ....

  • @BobbySingh-hu4zu
    @BobbySingh-hu4zu Před 4 lety

    Harry Bhai ek video Google sites par bana do, google sites aur wordpress me difference, etc.

  • @vaibhavsonawane1638
    @vaibhavsonawane1638 Před 2 lety +1

    Harry Bhai there's a MISTAKE in this code. When we give 9, 25 or 49 as an input it still shows that it is PRIME. Can you explain why is this happening?

  • @abhaykumawat195
    @abhaykumawat195 Před 2 lety

    Thanks bro

  • @Rajat_gandhi
    @Rajat_gandhi Před 4 lety +1

    Sir android development videos bana lo

  • @mrripergaming1839
    @mrripergaming1839 Před 4 lety

    congrats for 500 k harry bhai

  • @shinratenten5686
    @shinratenten5686 Před 2 lety

    you never disapoint me

  • @ashwanishukla8029
    @ashwanishukla8029 Před 4 lety

    Add bahut aane lgi hai bhai beech beech me😔 ,but chlo koi bat ni bhai free me etna achha content provide kra rahe hai👍👍

  • @niteshghosh1762
    @niteshghosh1762 Před 2 lety +1

    This code won't tell wheter 2 or 3 is a prime number or not...plz help anyone

  • @bookbang4596
    @bookbang4596 Před rokem

    You explained prime numbers like we used to learn in class 8

  • @roopamgupta515
    @roopamgupta515 Před 4 lety +2

    bro when are you bringing JAVA Tutorials?)

  • @salmanmushtaq7633
    @salmanmushtaq7633 Před 4 lety

    congratulations on 500k

  • @mahadeolokhande2996
    @mahadeolokhande2996 Před 7 měsíci

    for(int i=2; i*i

  • @pubggamerzone5077
    @pubggamerzone5077 Před 4 lety

    Please make course on Statistics and probability

  • @nikhilraj1842
    @nikhilraj1842 Před 4 lety

    500K Completed