Find Number of Days in a Month

Duration: 4 min

This video lesson is available to enrolled students.

Return to /learn/CAPGEMINI-PREPARATION/pseudo-code/coding-questions/coding-question/asset-find-number-of-days-in-a-month 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 programming tutorial from Knowledge Gate that teaches how to write a C program to determine the number of days in a given month. The instructor first presents the problem statement, Q10, which requires a user to input a date in dd-mm-yyyy format and output the number of days in that month, with the instruction to ignore leap years. The solution is broken down into a logical approach: parsing the input string to extract the month, using a predefined array of days for each month, and then outputting the result. The instructor then transitions to writing the code, showing the necessary header files, the main function, and the use of the `strtok` function to split the date string by the '-' delimiter. The code is completed by converting the month string to an integer and using it as an index to access the correct number of days from the array. The video concludes with the final code snippet and a brief explanation of the logic.

Chapters

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

    The video begins with the Knowledge Gate logo, followed by a slide introducing the problem, Q10. The problem statement is clearly displayed: 'User enters date in dd-mm-yyyy find out number of days in month (for now please ignore the concept of leap year)'. The input is specified as a date in dd-mm-yyyy format, and the output is the number of days in that month. Two public test cases are provided: for the date 12-03-2006, the output is 31, and for 31-11-1996, the output is 30. The instructor, Yash Jain Sir, is visible in a small window, and the slide includes a 'Placement Expert' graphic and a copyright notice for Knowledge Gate Eduventures. The instructor begins to explain the problem, emphasizing the need to parse the date string to extract the month.

  2. 2:00 – 4:18 02:00-04:18

    The instructor transitions to the coding phase, with a 'Code' label appearing on the screen. He begins writing the C program, starting with the necessary header files: #include <stdio.h> and #include <string.h>. He then defines the main function and initializes an integer array `arr` with the number of days for each month, starting from January (index 0). The array is populated as {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}. He then writes the code to take user input using `scanf`, store it in a character array `date[11]`, and use `strtok` to split the string by the '-' delimiter to extract the month. He explains that the month string is then converted to an integer using `atoi` and used as an index to access the correct number of days from the array, which is printed as the output. The final code snippet is shown on the screen, and the instructor explains the logic of the program.

The video provides a clear, step-by-step tutorial on solving a common programming problem. It starts with a well-defined problem statement and test cases, then logically breaks down the solution into parsing the input, using a data structure (an array) to store the number of days per month, and finally writing the code to implement this logic. The progression from problem definition to code implementation is methodical and educational, making it a useful resource for learning basic string manipulation and array usage in C.

Loading lesson…