Difference between Compile-time, Run-time and Logical errors in C (hands-on) | C Programming

Sdílet
Vložit
  • čas přidán 25. 08. 2024
  • Compile-time vs. Runtime vs. Logical errors in C programming.
    In this video, I will explain the difference between compile-time error, runtime error, and logical error in C programming. By the end of this video, you should be able to differentiate between these 3 types of errors in C.
    There are different types of errors in C - Compile time error, run-time error, and logical errors.
    Compile-time errors as the name say - occur during the compilation process. One best example of a compile-time error is a syntax error. Let’s say, you use printffs (typo) for printing text on the screen. If you try to compile your code, the C compiler will throw an error saying the program could not be compiled as it could not recognize printffs keyword. This is called compile-time error.
    Run time error occurs during the execution of the program. It can cause the program to crash if not handled during the coding process. The classic example is division by zero. If your code has division operation and if division by zero is not handled inside the code, the program will compile without any issue. However, if during program execution, the denominator turns out to be zero, the program will crash as division by zero is not a legal operation.
    Then we have a logical error. Logical error deals with the logic of the program code. Let’s say, I am writing a code that calculates an average of 3 numbers. The formula to calculate the average is (a+b+c)/3. However, while writing the code, I wrote (a+b)/3 instead of (a+b+c)/3. On compilation, the program will compile successfully and on execution, it will execute perfectly fine without throwing any run-time error. However, the calculation of the average of 3 numbers will be calculated incorrectly. Here, the logic written for calculation is incorrect. This is called logical error. This type of error will not make your program terminate unexpectedly. It will just add a bug in your program code which will result in unexpected output.
    Some helpful resources ##
    C programming course for beginners - www.aptuts.com...
    Learn C programming online for FREE - www.learnconli...
    Follow me on my Facebook page - aptuts
    Free C programming cheatsheet - www.aptuts.com...
    #aptuts #CProgramming #ErrorsInC

Komentáře • 47

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

    Superb and nice explanation

  • @ozzyfromspace
    @ozzyfromspace Před 3 lety +12

    So basically, compile time is when the program is checked for logical and syntactical consistency, and runtime is the actual execution of the program as you use it. Thanks.

    • @aptuts
      @aptuts  Před 3 lety +5

      I would not say logical consistency... Logical consistency deals with the programming logic and it is something that depends on the developer. Compile time is more about syntactical consistency...

  • @aptuts
    @aptuts  Před 3 lety

    Interested in learning C programming language? Visit my comprehensive C course - www.aptuts.com/c-programming

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

    short and crisp lecture... so satisfied

  • @JyotiRani-wk9qm
    @JyotiRani-wk9qm Před rokem +2

    thnx for explaining in a quite simple way..👍

  • @prernakhatri05
    @prernakhatri05 Před 5 měsíci +1

    Concept clear.

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

    It helped me a lot!!!!!! thnx.

  • @ChandanKumar-ni7ll
    @ChandanKumar-ni7ll Před 11 měsíci +1

    very well explained

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

    Nice class

  • @okaybossiamonyoutubeakkskd

    thank you bro, crisp and clear explanation.

  • @shubhangimahajan5089
    @shubhangimahajan5089 Před rokem +1

    Very nice explaination 👍

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

    Bro please make videos on C programming ,Java,python it will be really helpful! And btw the video was really nice 👍

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

    THANK U SIR

  • @payelkumbhakar6337
    @payelkumbhakar6337 Před rokem +1

    Very well explained.
    Mujhe ek chij janni hai ki jab hum program ke ek ek line code likhte hai to kya wo uss hi time pe compile ho jata hai ya fir pura program likhne ke baad compile hota hai?
    Please help me to clear my doubt.🙏
    Waiting for your reply.

    • @aptuts
      @aptuts  Před rokem +1

      The program gets compiled as soon as we instruct the code editor (IDE) to compile the code. It is possible to compile the code whenever we want. The code will not get compiled automatically. We have to instruct C compiler to compile it. We can do it after writing 1 line or we can compile the code after writing 5 lines of code. It is totally up to us when to compile.

    • @payelkumbhakar6337
      @payelkumbhakar6337 Před rokem +1

      @@aptuts thank you for the answer

  • @ParthDabhiOfficial
    @ParthDabhiOfficial Před 8 měsíci

    Thanks

  • @hishamyousufzai2328
    @hishamyousufzai2328 Před rokem +1

    Helpful Lecture ❤️

  • @man08839
    @man08839 Před 3 lety

    Thank you for sharing your kind information🧡

  • @florian_ariasu
    @florian_ariasu Před rokem +1

    Thanks!

  • @mohansiva1102
    @mohansiva1102 Před rokem

    Hai sir ,i have an one dout .why over riding is called as run time polymorphism?.why it's not told as compile time polymorphism?.what is the difference between together?..please advice me sir

  • @youtubejoker4566
    @youtubejoker4566 Před rokem +1

    Thank you sir

    • @aptuts
      @aptuts  Před rokem

      You are welcome! I am glad you found this video helpful.

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

    Sirwhy it will take time to run
    Void main()
    {
    Main()
    }

    • @aptuts
      @aptuts  Před 3 lety

      Hello... the above code will run indefinitely or until your computer run out of memory. Here in this case, inside main() you have a function call to main(). This will create indefinite loop and that is the reason why it is taking time for your program to end the execution.

  • @Legend-gx6je
    @Legend-gx6je Před 2 lety +2

    Op video 🔥🔥🔥

  • @priyanshisingh4135
    @priyanshisingh4135 Před 3 měsíci +1

    Is it same for cpp??

    • @aptuts
      @aptuts  Před 3 měsíci

      Yes… it works the same

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

    It takes nearly 7...to 8...sec

  • @SudeepSs-bm3ez
    @SudeepSs-bm3ez Před rokem +1

    Sir,how to find a logical erorr in run time

    • @aptuts
      @aptuts  Před rokem

      You won’t be able to find the logical error during run time as logical error won’t throw any error during run time. The only is to check the results after run time and compare it with the expected results.

  • @pavan_hitech6567
    @pavan_hitech6567 Před 3 lety

    Upload vedios on data structures bro.....

    • @aptuts
      @aptuts  Před 3 lety

      Thank you for your suggestion. Will definitely plan to work on it. 👍🏻

  • @sauravsingh8081
    @sauravsingh8081 Před 3 lety

    Can compile time and run time errors occurs together in any case

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

      No. Compile time and run time errors can't happen together. Reason being, when ever we try to run a program, it is compiled first. If compilation process is successful then C compiler will create an executable and program is executed. Run time error occurs during run time.unless and until program is compiled successful, program won't run.

  • @bharatbhaivaghasiya3466

    Very nice explanation. where are you from sir?

    • @aptuts
      @aptuts  Před 3 lety

      Thank you so much. I am from India :)

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

    nice
    :)