How Sizeof(char) behave differently in C & C++
Duration: 8 min
This video lesson is available to enrolled students.
Inside: a video lesson and guided study material.
Module outline
- TCS One Shot Free Videos & Notes: TCS Preparation
- Numerical Ability (Foundation Section): Ratio and Proportion (Ratios), Divisibility Rules, Data Interpretation, Mixture and Alligation, Permutation and Combination, Logarithm, Number System, HCF LCM, Sequence and Series (Series), Speed Time and Distance, Percentage, Average, Powers and Exponents (Surds and Indices), Algebra, Probability, Profit and Loss, Simple Interest and Compound Interest, Time and Work, Pipe and Cistern, Mensuration and Geometry, Mental Ability, Age Problems, Statistics, Arithmetic, Partnership, Speed Mathematics and Basic Mathematics
- Reasoning Ability (Foundation Section): Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Syllogisms, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Seating Arrangements, Blood Relations, Directions (Direction Test), Analytical Reasoning (Counting Figures Reasoning), Puzzle Solving (Puzzles), Calendar, Clock, Cubes & Dices, Selection Decision Table (Decision Making), Crypt Arithmetic, Venn Diagram, Data Arrangement, Inequality, Analogy, Ranking, Order and Sequence, Logical Sequence Of Words
- New Pattern-Verbal Ability (Foundation Section): Sentence Completion (Fill in the blanks), English Writing Ability
- Old Pattern-Verbal Ability (Foundation Section): Vocabulary, Noun, Subject Verb Agreement (Verb Noun Agreement), Adjectives, Tenses, Pronoun, Preposition, Articles, Direct and Indirect Speech, Conjunction, Modals, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Sentence Correction (Error Correction), Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Verbal Analogy (Word Based Analogy), Active Passive Voice (Voice), Determiner, Facts, Inference and Judgements, Adverb, Cloze Test (Cloze Passage), Sentence Construction, Verb
- Advanced Quantitative Ability: TCS NQT Advanced Quantitative Ability
- Advanced Reasoning Ability: TCS NQT Advanced Reasoning Ability
- Advanced Coding: Coding Questions by Yash Sir, C Programming by Yash Sir, Python for Placements by Yash Sir, DSA using Python, Object Oriented Programming (OOPS), Programming in C++, Java
- TCS Full Length Mock Test:
- TCS Interview & Resume Prep: MR & HR Interview Preparation, TCS Interview Preparation, Mock Interview, Interview Recordings, Resume Preparation, Resume Review
- Mega Test:
- Grand Test:
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
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: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.
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.

