How Sizeof(char) behave differently in C & C++

Duration: 8 min

This video lesson is available to enrolled students.

Return to /learn/COGNIZANT-PREPARATION/technical-assessment/programming-in-c/c-mcqs-by-yash-sir/asset-how-sizeofchar-behave-differently-in-c-c after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Communication Round: Vocabulary, Subject Verb Agreement (Verb Noun Agreement), Tenses, Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Cloze Test (Cloze Passage), Sentence Correction (Error Correction), Sentence Completion (Fill in the blanks), Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Direct and Indirect Speech, Active Passive Voice (Voice), Verbal Analogy (Word Based Analogy), Articles, Preposition, Conjunction, Sentence Construction, English Writing Ability, Communication Assessment
  2. Quantitative Aptitude: Ratio and Proportion (Ratios), Divisibility Rules, Data Interpretation, Mixture and Alligation, Permutation and Combination, Logarithm, Number System, HCF LCM, Speed Time and Distance, Percentage, Average, Powers and Exponents (Surds and Indices), Time and Work, Mensuration and Geometry, Age Problems, Pipe and Cistern, Probability, Profit and Loss, Simple Interest and Compound Interest, Algebra
  3. Analytical and Logical Reasoning: Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Directions (Direction Test), Ranking, Order and Sequence, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Selection Decision Table (Decision Making), Logical Sequence Of Words, Puzzle Solving (Puzzles), Syllogisms, Seating Arrangements, Calendar, Clock, Blood Relations, Cubes & Dices, Venn Diagram, Analytical Reasoning (Counting Figures Reasoning)
  4. Cognizant Gaming Aptitude: Gamified / Game Based Aptitude
  5. Java (Cluster 1): Java
  6. ANSI SQL MySQL (Cluster 1,2,3): SQL
  7. HTML, CSS, JavaScript (Cluster 1,3): HTML, CSS, JavaScript
  8. Python (Cluster 2): Python for Placements by Yash Sir
  9. Cloud Fundamentals (Cluster 2): Emerging Tech Trends
  10. C# (Cluster 3): C#
  11. OOPs: Object Oriented Programming (OOPS)
  12. Technical Assessment (Coding): Coding Questions by Yash Sir, C Programming by Yash Sir, Programming in C++, Pseudo Codes
  13. Data Structures: Introduction to DS, Array, Stack, Queue, Linked List, Tree, Graphs, Hashing
  14. DBMS: 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, ORDBMS, Database Security & Authorization, Query Processing & Optimization, Enhanced Data Models, Data Warehousing & Mining, Big Data Systems, NoSQL
  15. Operating Systems: Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Deadlock, Threads & Process Creation, Memory Management, Virtual Memory, Disc Scheduling, File Management, Windows OS, Linux OS, Security, Distributed Systems, Virtual Machines
  16. Computer Networks: 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, TL: Congestion & UDP, Application Layer, Hardware basics, Network Security, Mobile Technology, Cloud Computing and IoT, Cyber and Info Security
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This educational video is a lecture on the C and C++ programming languages, focusing on the `sizeof` operator. The instructor begins by introducing the topic with a slide comparing C and C++ and then transitions to a detailed explanation of the `sizeof` operator. The core of the lecture involves a side-by-side comparison of C and C++ code examples, demonstrating how to use `sizeof` to determine the size of data types like `char` and character literals. The instructor uses an online IDE, OnlineGDB, to run the code and show the output, which is 1 for a `char` and 1 for the character literal 'x'. The lecture concludes with a detailed analysis of the ASCII value of 'x' (65) and the size of the `char` data type, which is 1 byte, reinforcing the concept that the size of a `char` is always 1 byte in C and C++. The video is structured as a clear, step-by-step tutorial for students learning programming fundamentals.

Chapters

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

    The video opens with a presentation slide titled 'C++ PROGRAMMING' with a background of C++ code. The instructor, Yash Jain, is visible in a small window in the bottom right corner. The slide transitions to a new one that compares C and C++ with a 'VS' graphic. The main topic is introduced as the 'sizeof operator', which is displayed on a computer monitor graphic. The instructor begins to explain the concept, setting the stage for a detailed discussion on the `sizeof` operator in C and C++.

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

    The instructor displays two code snippets side-by-side: one in C and one in C++. The C code uses `#include <stdio.h>` and `printf`, while the C++ code uses `#include <iostream>` and `cout`. Both snippets contain the `sizeof` operator to find the size of a character literal 'x' and the `char` data type. The instructor then switches to the OnlineGDB IDE, where he runs the C code. The output shows that the size of 'x' is 1 and the size of `char` is 1. He then runs the C++ code, which also outputs 1 for both `sizeof('x')` and `sizeof(char)`, demonstrating that the size is consistent across both languages for these types.

  3. 5:00 – 7:34 05:00-07:34

    The instructor returns to the presentation slide with the C and C++ code. He uses a yellow highlighter to annotate the code, writing '65' next to the character 'x' to represent its ASCII value. He then writes '1 byte' next to the `char` data type, explaining that the size of a `char` is always 1 byte. He circles the number 1 in the output, reinforcing that the size of a character literal and the `char` data type is 1 byte. The video concludes with a final summary of the key takeaway: the `sizeof` operator returns the size of a data type or value in bytes, and for a `char`, this is always 1 byte.

The video provides a clear and structured lesson on the `sizeof` operator in C and C++. It begins with a conceptual introduction, then moves to a practical demonstration using an online IDE to show the output of the operator for character types. The instructor effectively uses visual annotations to explain the relationship between the ASCII value of a character and its size in memory, reinforcing the fundamental concept that a `char` occupies 1 byte. The progression from theory to code execution and then to a detailed analysis ensures a comprehensive understanding of the topic for the student.

Loading lesson…