Formatted String Output + Suppression Character

Duration: 13 min

This video lesson is available to enrolled students.

Return to /learn/COGNIZANT-PREPARATION/technical-assessment/c-programming-by-yash-sir/c-language-mcqs/asset-formatted-string-output-suppression-character 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 C programming, specifically focusing on the behavior of the printf function with format specifiers for strings and integers. The instructor begins by introducing the topic of C programming MCQs and then delves into the concept of precision in the printf function, using the format specifier %.3s. He explains that this specifier limits the output to a maximum of three characters from the string, even if the string is longer, and demonstrates this with the string "abcdef". The lecture then transitions to a more complex example involving the scanf function with the format specifier %*d, which is used to read an integer but discard it (i.e., not store it in a variable). The instructor uses this to illustrate a common source of bugs in C programming, where an incorrect format string can lead to undefined behavior, such as reading garbage values. The video concludes with a final example of a C program that uses scanf and printf, and the instructor walks through the logic of the program to determine its output when given specific inputs.

Chapters

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

    The video opens with a title slide for a C programming MCQs lecture by Yash Jain. The instructor then transitions to a blackboard-style presentation, where he begins to explain the printf function. He writes the code snippet `#include <stdio.h> int main() { printf("%.3s", "abcdef"); return 0; }` and starts to explain the format specifier `%.3s`. He uses the board to write the number `3` and explains that this number represents the precision, which limits the number of characters printed from the string. He also writes the word "overall" and "decimal" to describe the components of the format specifier.

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

    The instructor continues to explain the `%.3s` format specifier. He writes the number `4.2` on the board and explains that the `4` represents the minimum field width, and the `.2` represents the precision. He then circles the `3` in `%.3s` and explains that this is the precision, which limits the number of characters printed. He writes the word "max" and "char" to indicate that the precision is the maximum number of characters that can be printed. He also writes the word "overall" and "min" to describe the components of the format specifier. He then writes the word "exact" to indicate that the precision is the exact number of characters that will be printed.

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

    The instructor moves on to a new example, writing the code snippet `#include <stdio.h> int main() { int a, b, c; scanf("%*d%d", &a, &b, &c); printf("%d %d %d", a, b, c); return 0; }`. He explains that the format specifier `%*d` is used to read an integer but discard it, meaning it will not be stored in a variable. He writes the word "suppression" and "character" to describe the `*` in the format specifier. He then explains that the `*` is used to suppress the input, meaning it will not be stored in a variable. He writes the word "garbage" to indicate that the value of `a` will be garbage because it was not stored. He also writes the word "min" and "max" to describe the components of the format specifier.

  4. 10:00 – 13:14 10:00-13:14

    The instructor presents a final example, writing the code snippet `#include <stdio.h> int main() { int a, b, c; scanf("%*d%d", &a, &b, &c); printf("%d %d %d", a, b, c); return 0; }`. He explains that the format specifier `%*d` is used to read an integer but discard it, meaning it will not be stored in a variable. He then explains that the `*` is used to suppress the input, meaning it will not be stored in a variable. He writes the word "garbage" to indicate that the value of `a` will be garbage because it was not stored. He also writes the word "min" and "max" to describe the components of the format specifier. He then explains that the `*` is used to suppress the input, meaning it will not be stored in a variable. He writes the word "garbage" to indicate that the value of `a` will be garbage because it was not stored. He also writes the word "min" and "max" to describe the components of the format specifier.

The video provides a comprehensive lecture on C programming, focusing on the nuances of format specifiers in the printf and scanf functions. The instructor effectively uses a blackboard-style presentation to break down complex concepts into digestible parts. The core of the lesson revolves around the precision specifier in printf, demonstrating how it limits the number of characters printed from a string. The video then transitions to a more advanced topic, illustrating the use of the `*` in scanf to suppress input, which is a common source of bugs. The instructor's methodical approach, combining code examples with on-screen annotations, makes the material accessible and reinforces key concepts for students preparing for exams like GATE and Accenture.

Loading lesson…