Check if a number is divisible by 3 or 5 or both using Programming

Duration: 6 min

This video lesson is available to enrolled students.

Return to /learn/CAPGEMINI-PREPARATION/pseudo-code/programming-in-c/c-by-yash-sir/asset-check-if-a-number-is-divisible-by-3-or-5-or-both-using-programming after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. English Communication: Communication Assessment, English Writing Ability, Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions)
  2. Artificial Intelligence (AI Literacy): AI & ML by Arun Sir
  3. Programming, Logic & Problem Solving (Technical Assessment): Language Design, Pseudo Codes
  4. DSA (Technical Assessment): Introduction to DS, Array, Stack, Queue, Linked List
  5. Software Engineering (Technical Assessment): Fundamentals of Software Engineering, Software Requirements and Quality Assurance, Software Design, Estimation and Metrics, Software Testing, Software Maintenance and Configuration Management
  6. OOPs (Technical Assessment): Object Oriented Programming (OOPS)
  7. DBMS (Technical Assessment): Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, File Organization & Indexing, Relational Algebra, Relational Calculus, Transaction Management, Concurrency Control, Database Recovery, Database Security & Authorization, Data Warehousing & Mining, NoSQL
  8. SQL (Technical Assessment): SQL
  9. Networking (Technical Assessment): Introduction to CN, Data Communication, DLL: Access Control, DLL: Flow Control, DLL: Error Control, DLL: Framing, Net Layer: IPv4 & Proto, Net Layer: IP Addressing, Net Layer:Routing Protocol, Transport Layer Services, TL: Congestion & UDP, Application Layer, Hardware basics, Network Security
  10. Modern Engg Awareness (Technical Assessment): Emerging Tech Trends, Cyber and Info Security
  11. Debugging Assessment: Coding Questions by Yash Sir, C Programming by Yash Sir, Programming in C++, Java
  12. Cognitive Assessment: Gamified / Game Based Aptitude, Seating Arrangements, Puzzle Solving (Puzzles), Data Arrangement, Blood Relations, Directions (Direction Test), Coding Decoding, Series (Number and Letter Series) (Numerical Relations and Reasoning), Logical Sequence Of Words, Ranking, Order and Sequence, Data Sufficiency, Inequality, Venn Diagram, Syllogisms, Cubes & Dices, Calendar, Clock, Analytical Reasoning (Counting Figures Reasoning), Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Selection Decision Table (Decision Making), Behavioral Assessment (Behavioral Competency Profiling) (Psychometric Test)
  13. HR Interview: MR & HR Interview Preparation
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This video is a coding tutorial demonstrating how to write a C++ program to check if a number is divisible by 3 or 5 or both. The instructor, Yash Jain, presents a complete program in an online IDE, explaining the logic and syntax. The core of the program uses the modulo operator (%) to check divisibility. The condition `if (n % 3 == 0 || n % 5 == 0)` evaluates to true if the number is divisible by 3, by 5, or by both, and the program outputs a corresponding message. The instructor walks through the code, highlighting the `if-else` structure and the logical OR operator (`||`). The video concludes with a demonstration of the program's execution, showing the output for a test case where the input is 3, which is divisible by 3, resulting in the message 'Given number is divisible by 3 or 5 or both'.

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The video opens with a C++ code editor displaying a program titled 'Finding if a number is divisible by 3 or 5 or both'. The code includes standard C++ headers and a main function. The instructor explains the program's purpose and begins to write the code, starting with the `#include <iostream>` and `using namespace std;` statements. He then defines the `int main()` function and declares an integer variable `n`. The next step is to prompt the user for input with `cout<<"Enter the number: ";` and read the value with `cin>>n;`. The core logic is introduced with an `if` statement: `if(n % 3 == 0 || n % 5 == 0)`, which checks if the number is divisible by 3 or 5. The instructor explains that the `||` operator means 'or', so the condition is true if either part is true. The program then outputs a message if the condition is met, and an alternative message if it is not, using an `else` clause.

  2. 2:00 – 5:00 02:00-05:00

    The instructor continues to explain the program's logic, focusing on the `if` condition `if(n % 3 == 0 || n % 5 == 0)`. He emphasizes that the modulo operator `%` returns the remainder of a division. If the remainder is 0, the number is divisible. He explains that the condition will be true if the number is divisible by 3, by 5, or by both. He then demonstrates the program's execution by running it. The console output shows the prompt 'Enter the number:'. The instructor types '3' as the input. The program evaluates the condition: `3 % 3 == 0` is true, and `3 % 5 == 0` is false. Since the logical OR (`||`) only requires one condition to be true, the entire expression is true. The program executes the `if` block and prints 'Given number is divisible by 3 or 5 or both'. The instructor then shows the program's output in the console, which also displays '...Program finished with exit code 0' and 'Press ENTER to exit console.' He briefly mentions that the condition can be written as `if(n % 3 == 0 || n % 5 == 0)` and that the `||` operator is a logical OR.

  3. 5:00 – 5:47 05:00-05:47

    The instructor concludes the tutorial by summarizing the key concepts. He reiterates that the program uses the modulo operator to check for divisibility and the logical OR operator to combine two conditions. He confirms that the program correctly identifies numbers divisible by 3, 5, or both. The final code is shown in the editor, with the `if` condition `if(n % 3 == 0 || n % 5 == 0)` and the corresponding `cout` statements. The video ends with the instructor's final remarks, and the screen shows the completed code and the successful execution output for the input 3.

The video provides a clear, step-by-step tutorial on implementing a fundamental logic problem in C++. It begins by establishing the necessary C++ syntax and then focuses on the core algorithm: using the modulo operator to check divisibility and the logical OR operator to combine conditions. The instructor effectively demonstrates the program's logic and then validates it with a live run, showing the correct output for a test case. The progression from code writing to execution provides a complete learning experience for a beginner.

Loading lesson…