How to take input from user
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 C++ programming tutorial that demonstrates how to write a program to calculate the square of a number. The instructor begins by showing a basic C++ program in an online IDE, which includes the necessary header files and the main function. The initial code uses a hardcoded value for the number, but the instructor then modifies it to accept user input using the cin statement. The program is executed with different inputs, such as 5 and 10, to show the output. The tutorial then transitions to a more advanced example, where the program calculates a number raised to a power, requiring the user to input both the base and the exponent. The instructor also shows how to use the pow() function from the math.h library to perform this calculation. The video includes a brief interlude where the instructor searches for the formula for the area of an equilateral triangle, which is presented as a visual aid. The overall teaching style is practical and hands-on, focusing on writing, modifying, and running code in real-time.
Chapters
0:00 – 2:00 00:00-02:00
The video opens with a C++ code editor displaying a program to calculate the square of a number. The code includes the necessary headers #include <iostream> and using namespace std; and defines the main function. The instructor explains the structure of a C++ program. The initial code has a float variable x initialized to 5, and it prints the square of x. The instructor then modifies the code to prompt the user to enter a number, using cout to display "Enter Number:" and cin to read the input into the variable x. The output statement is updated to print the square of the entered number. The instructor runs the program, and the console output shows the result for the input 5, which is 25. The instructor also mentions that the program can be run with different values, such as 10, to get the square of 100.
2:00 – 5:00 02:00-05:00
The instructor continues to demonstrate the C++ program for calculating the square of a number. The code is shown with the variable x initialized to 10, and the program is run to show the output of 100. The instructor then modifies the code to use the pow() function from the math.h library to calculate the square, which is shown as pow(x,2). The instructor explains that this method is more flexible for calculating powers other than 2. The video then transitions to a new topic, showing a Google search for the formula of the area of an equilateral triangle. The formula A = (√3/4) * a² is displayed, along with a diagram of the triangle. The instructor uses this as an example to illustrate how to apply the concept of calculating powers in a real-world scenario, such as calculating the area of a triangle with a given side length.
5:00 – 8:18 05:00-08:18
The video returns to the C++ code editor, where the instructor demonstrates a more advanced program to calculate a number raised to a power. The code includes the necessary headers, including #include <math.h>. The program prompts the user to enter a number and a power, and then calculates the result using the pow() function. The instructor shows the code being written and executed, with the console output displaying the result of 5 raised to the power of 4, which is 625. The instructor explains that this method is more efficient than manually multiplying the number by itself multiple times. The video concludes with the instructor summarizing the key concepts covered, including how to take user input, perform calculations, and use the pow() function in C++.
The video provides a comprehensive, step-by-step tutorial on C++ programming, starting with the basics of writing a program to calculate the square of a number and progressing to more advanced concepts like user input and using the pow() function. The instructor uses a practical, hands-on approach, demonstrating code modifications and running the program to show the results. The inclusion of a real-world example, the area of an equilateral triangle, helps to contextualize the mathematical operations. The overall lesson emphasizes the importance of understanding the structure of a C++ program, how to interact with the user, and how to use built-in functions to perform complex calculations efficiently.

