Find whether a given number is perfect square or not?

Duration: 5 min

This video lesson is available to enrolled students.

Return to /learn/DELOITTE-NLA/technical-skills-coding/coding-questions/coding-question/asset-find-whether-a-given-number-is-perfect-square-or-not after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Language Skills (English): Vocabulary Verbal Analogy (Word Based Analogy) Noun Pronoun Verb Adjectives Adverb Preposition Articles Conjunction Tenses Modals Subject Verb Agreement (Verb Noun Agreement) Determiner Active Passive Voice (Voice) Direct and Indirect Speech Sentence Correction (Error Correction) Sentence Completion (Fill in the blanks) Sentence Construction Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing) Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions) Cloze Test (Cloze Passage)
  2. General Aptitude (Quantitative Ability): Percentage Ratio and Proportion (Ratios) Average Profit and Loss Simple Interest and Compound Interest Time and Work Pipe and Cistern Speed Time and Distance Mixture and Alligation Age Problems Partnership Number System HCF LCM Divisibility Rules Powers and Exponents (Surds and Indices) Algebra Data Interpretation Statistics Sequence and Series (Series) Logarithm Arithmetic
  3. General Aptitude (Reasoning Ability): Series (Number and Letter Series) (Numerical Relations and Reasoning) Coding Decoding Syllogisms Blood Relations Directions (Direction Test) Ranking, Order and Sequence Inequality Logical Sequence Of Words Seating Arrangements Puzzle Solving (Puzzles) Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning) Cubes & Dices Venn Diagram Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning) Selection Decision Table (Decision Making) Analytical Reasoning (Counting Figures Reasoning) Clock Calendar Data Sufficiency Analogy
  4. Technical Skills MCQ - Data Structure: Introduction to DS Array Stack Queue Linked List Tree Graphs Hashing
  5. Technical Skills MCQ - Networking: Introduction to CN Data Communication DLL: Access Control DLL: Flow Control DLL: Error Control DLL: Framing Data Link Layer - Ethernet Net Layer: IPv4 & Proto Net Layer: IP Addressing Net Layer:Routing Protocol Transport Layer Services Application Layer Network Security
  6. Technical Skills MCQ - Operating System: Introduction to OS Process Management CPU Scheduling Process Synchronization Deadlock Threads & Process Creation Memory Management Virtual Memory File Management Windows OS Linux OS Security Virtual Machines
  7. Technical Skills MCQ - DBMS: Basics of DBMS ER Diagram Relational Model & Functional Dependencies Keys & Integrity Constraints Normalization (1NF - BCNF) File Organization & Indexing Relational Algebra SQL Transaction Management Concurrency Control Database Recovery Database Security & Authorization NoSQL
  8. Technical Skills MCQ - Software Engineering: Fundamentals of Software Engineering Software Requirements and Quality Assurance Software Design, Estimation and Metrics Software Testing Software Maintenance and Configuration Management
  9. Technical Skills MCQ - Cloud Computing: Cloud Computing and IoT
  10. Technical Skills MCQ - Cyber Security: Cyber and Info Security Security in Mobile and Wireless Computing
  11. Technical Skills (Coding): Coding Questions by Yash Sir C Programming by Yash Sir Programming in C++ Java Python for Placements by Yash Sir Object Oriented Programming (OOPS) DSA by Prashant sir Coding Questions Bank
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This video is a programming tutorial from Knowledge Gate Eduventures, presented by instructor Yash Jain Sir, that teaches how to determine if a given positive integer is a perfect square. The lesson begins with a problem statement (Q11) displayed on a digital chalkboard, which requires a program to output 'Success' for a perfect square and 'Failure' otherwise, with test cases provided. The instructor then explains the core logic: a number is a perfect square if its square root, when converted to an integer, when squared again, equals the original number. This is demonstrated with examples like 25 (sqrt is 5, 5*5=25) and 26 (sqrt is 5.099, 5*5=25, not 26). The final part of the video shows the implementation of this logic in C code, using the `sqrt()` function from the `math.h` library, and a conditional check to validate the result. The video is structured as a step-by-step guide, moving from problem definition to logical reasoning and finally to a working code solution.

Chapters

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

    The video opens with the 'KNOX MEEHEGATF' logo, which is a stylized version of 'KNOWLEDGE GATE'. It then transitions to a presentation slide for 'KNOWLEDGE GATE' with four social media handles for different educational streams. The main content begins with a problem statement (Q11) on a digital chalkboard: 'Program to find whether a number is perfect square or not.' The input is defined as 'Any integer positive number' and the output as 'Print Success if the input number is a perfect square and failure if the input number is not a perfect square.' Two public test cases are shown: Input 625, Output 'Success', and Input 1002, Output 'Failure'. The instructor, Yash Jain Sir, is visible in a small window at the bottom right, and the video is watermarked with 'clideo.com' and a copyright notice for Knowledge Gate Eduventures.

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

    The instructor begins explaining the logic for solving the problem. A green box labeled 'Logic' appears on the chalkboard. He demonstrates the concept with examples: for 25, the square root is 5, and 5 squared is 25, so it is a perfect square. For 26, the square root is approximately 5.099, which is a float. He writes '26 -> 5.24 (float)' and then shows that if this float is cast to an integer, it becomes 5. He explains that the key is to check if the integer value of the square root, when squared, equals the original number. He draws a diagram showing the process: take the number, find its square root, convert it to an integer, and then square that integer to see if it matches the original number. This logic is the foundation for the code that will be written.

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

    The video transitions to the 'Code' section, with a green box labeled 'Code' on the chalkboard. The instructor displays a C program. The code includes the necessary headers: `#include <stdio.h>` and `#include <math.h>`. The `main()` function is defined. Inside, two variables are declared: `int n, intvar;`. The program uses `scanf("%d", &n);` to read the input. It then calculates the square root of `n` as a double: `double floatvar = sqrt((double)n);`. The double value is then cast to an integer: `intvar = (int)floatvar;`. The core logic is implemented with an `if` statement: `if (intvar * intvar == n)`. If true, it prints "Success"; otherwise, it prints "Failure". The instructor explains this code line by line, confirming it implements the logic discussed earlier.

The video provides a comprehensive, step-by-step tutorial on solving a common programming problem. It starts by clearly defining the problem and its expected inputs and outputs. The instructor then breaks down the solution into a logical concept, using mathematical examples to illustrate the principle of checking if a number is a perfect square by comparing the square of its integer square root to the original number. This logical foundation is then directly translated into a complete, functional C program. The progression from problem statement to logical reasoning to code implementation is clear and pedagogically sound, making it an effective learning resource for students preparing for coding interviews or competitive programming.

Loading lesson…