ToMotion AI logo
Menu
Back to gallery

Public AI explainer video

Control Flow and Prime Number Check in C

The modulo operator gives the remainder after division. For example, 7 modulo 2 is 1, because 7 divided by 2 leaves remainder 1. But 12 modulo 3 is 0....

Prompt

Source idea used to generate this video.

Use following content & Explain it in hindi but in romanhindi, dont use hindi hard words, use English words for English Terms. Explain in Tutor Style, Also dont write Hindi words while explaining, only English letters can be used. Control Flow Structures with Write programs in c for prime number checks; explain the code step by step in online GDB

Narration

Narration used to create this video.

Video narration

The modulo operator gives the remainder after division. For example, 7 modulo 2 is 1, because 7 divided by 2 leaves remainder 1. But 12 modulo 3 is 0. A zero remainder means exact division. Here is the key moment: when any divisor gives remainder 0, the number is not prime. If every check finishes without that, it is prime. Finally, use if isPrime to print either Prime number or Not a prime number. Now run it in Online GDB with input 13. The loop checks 13 modulo 2, which leaves 1. Then 13 modulo 3 leaves 1. The next value would be 4, but 4 times 4 is greater than 13, so the loop stops. The flag is still 1, and the output says Prime number. Run it again with 12. At i equal to 2, 12 modulo 2 is 0. The program changes isPrime to 0, breaks the loop, and prints Not a prime number. It does not waste time checking more values, just as you stop examining a shopping-list item once you know you do not need it. So the answer is simple: check each possible divisor like each item on your shopping list. If one divides with remainder 0, it is non-prime; after all needed checks pass, it is prime.