Placement Preparation 
C++ Basics 
Shreyas Basarge
Target Audience 
People who have no prior coding experience, 
didn’t take CS101 seriously but want to learn 
some basics of coding quickly. 
If you know how write a program to print 
fibonacci numbers, do NOT waste your time by 
attending this tutorial.
Motivation 
1. Most companies visiting IIT Guwahati 
require coding skills. 
2. Everyone wants to get placed. 
1 & 2 => You have to learn coding
Motivation
Hello World 
Your first fully functional program:
Running C++ code 
Linux: 
1. Install g++ 
2. g++ file_name.cpp 
3. ./a.out 
Windows: 
1. Open your favorite IDE 
2. Write some code 
3. Click the ‘play’ button 
n00b: 
1. Go to ideone.com 
2. Write some code. Select language (C++) 
3. Click on Run
Variables 
Letters in which we can store numbers and other data like 
user input. 
Example: 
int x = 42; 
int y; 
y = x + 10; 
int z; 
cin >> z; // whatever user types in is stored in z 
cout << z; // whatever is in z is shown on the screen
Variables 
Example: Find square of a number
Variables 
Demo: 
1. Take two integers from the user. 
2. Find sum of their cubes. (If user’s numbers 
are 2 and 3, output should be 
2x2x2 + 3x3x3 = 8 + 27 = 35)
Variables 
Variables can store integers, real numbers and 
some other things. 
int x; // x can store an integer 
x = 3; 
float y; // y can store a real number 
y = 3.14;
Variables 
Example: Find hypotenuse of a right angled 
triangle.
if-else 
When you want to do different 
things depending on some 
condition. 
Example: Write a program to 
find absolute value of given 
integer.
if-else
if-else 
if (x>3 || y<9) { … 
if (x>8 && y<4) { … 
if (x == 0) { … 
if (x*y >= 100) { … 
if (x != 7) { ...
if-else
loops 
Example: display all numbers from 1 to 20
loops 
Demo: Sum numbers from 1 to n.
loops 
The ‘for loop’
loops 
Demo: Sum of all even numbers from 1 to 100
Examples 
1. Check if number is prime 
2. Print the pattern: 
# 
## 
### 
#### 
3. Find all triplets that sum to 10
Examples 
4. Print fibonacci series 
5. Find square root of x

More Related Content

PPS
T02 a firstcprogram
PDF
CP Handout#7
PPTX
Operators
DOCX
Check the following function headers and locate as many errors you ca
DOCX
Programming fundamentals
PPS
C programming session 03
PPTX
C programming Tutorial Session 4
PDF
25422733 c-programming-and-data-structures-lab-manual
T02 a firstcprogram
CP Handout#7
Operators
Check the following function headers and locate as many errors you ca
Programming fundamentals
C programming session 03
C programming Tutorial Session 4
25422733 c-programming-and-data-structures-lab-manual

What's hot (20)

DOCX
Exercises
PPTX
2. introduction of a c program
PPT
DOCX
Bti1022 lab sheet 9 10
PDF
Type Conversion in C++ and C# Arithmetic Expressions
PDF
First c program
PDF
Arraysincv109102017 180831194256
PPTX
Introduction to C programming
PPTX
C Programming Language Part 11
PPTX
C programming codes for the class assignment
DOCX
Taller número 1 de informática ll
PPTX
Matlab introduction
PDF
Lesson 11. Pattern 3. Shift operations
PPTX
Cse 121 presentation on matrix [autosaved]
PPT
comp1
DOC
Devry cis 115 final exam 3
PDF
C programing Tutorial
DOCX
Flow chart
PPTX
comp2
PPTX
Questions on rational number
Exercises
2. introduction of a c program
Bti1022 lab sheet 9 10
Type Conversion in C++ and C# Arithmetic Expressions
First c program
Arraysincv109102017 180831194256
Introduction to C programming
C Programming Language Part 11
C programming codes for the class assignment
Taller número 1 de informática ll
Matlab introduction
Lesson 11. Pattern 3. Shift operations
Cse 121 presentation on matrix [autosaved]
comp1
Devry cis 115 final exam 3
C programing Tutorial
Flow chart
comp2
Questions on rational number
Ad

Similar to Lecture 1: basic syntax (20)

PPT
C tutorial
DOC
Project two c++ tutorial
PPT
C++ for beginners
DOC
Enrich enriching mathematics conversi biner 16 pada sisikomputerize indoensia...
PPTX
Computer science principals in terms of Programming
PPTX
Basic Programming concepts - Programming with C++
PPT
C C++ tutorial for beginners- tibacademy.in
PDF
C++ in 10 Hours.pdf.pdf
PPT
270_1_CIntro_Up_To_Functions.ppt
PPT
270 1 c_intro_up_to_functions
PPT
Survey of programming language getting started in C
PPT
270_1_CIntro_Up_To_Functions.ppt
PPT
270_1_ChapterIntro_Up_To_Functions (1).ppt
PDF
4. programing 101
PPT
CIntro_Up_To_Functions.ppt;uoooooooooooooooooooo
PPT
270_1_CIntro_Up_To_Functions.ppt 0478 computer
PPT
Lập trình C
PPSX
CS106 Lab 6 - While and Do..While loop
C tutorial
Project two c++ tutorial
C++ for beginners
Enrich enriching mathematics conversi biner 16 pada sisikomputerize indoensia...
Computer science principals in terms of Programming
Basic Programming concepts - Programming with C++
C C++ tutorial for beginners- tibacademy.in
C++ in 10 Hours.pdf.pdf
270_1_CIntro_Up_To_Functions.ppt
270 1 c_intro_up_to_functions
Survey of programming language getting started in C
270_1_CIntro_Up_To_Functions.ppt
270_1_ChapterIntro_Up_To_Functions (1).ppt
4. programing 101
CIntro_Up_To_Functions.ppt;uoooooooooooooooooooo
270_1_CIntro_Up_To_Functions.ppt 0478 computer
Lập trình C
CS106 Lab 6 - While and Do..While loop
Ad

More from Vivek Bhargav (10)

PPTX
Lecture 11.2 : sorting
PPTX
Lecture 11.1 : heaps
PPTX
Lecture 10 : trees - 2
PPTX
Lecture 9: Binary tree basics
PPTX
Lecture 7 & 8: Stack & queue
PPTX
Lecture 6: linked list
PPTX
Lecture 5: Asymptotic analysis of algorithms
PPTX
Lecture 4: Functions
PPTX
Lecture 3: Strings and Dynamic Memory Allocation
PPTX
Lecture 2: arrays and pointers
Lecture 11.2 : sorting
Lecture 11.1 : heaps
Lecture 10 : trees - 2
Lecture 9: Binary tree basics
Lecture 7 & 8: Stack & queue
Lecture 6: linked list
Lecture 5: Asymptotic analysis of algorithms
Lecture 4: Functions
Lecture 3: Strings and Dynamic Memory Allocation
Lecture 2: arrays and pointers

Recently uploaded (20)

PDF
Engineering Solutions for Ethical Dilemmas in Healthcare (www.kiu.ac.ug)
PPT
UNIT-I Machine Learning Essentials for 2nd years
PPTX
Agentic Artificial Intelligence (Agentic AI).pptx
PDF
CELDAS DE COMBUSTIBLE TIPO MEMBRANA DE INTERCAMBIO PROTÓNICO.pdf
PDF
AIGA 012_04 Cleaning of equipment for oxygen service_reformat Jan 12.pdf
PDF
Principles of operation, construction, theory, advantages and disadvantages, ...
PDF
IAE-V2500 Engine for Airbus Family 319/320
PDF
IAE-V2500 Engine Airbus Family A319/320
DOCX
ENVIRONMENTAL PROTECTION AND MANAGEMENT (18CVL756)
DOCX
An investigation of the use of recycled crumb rubber as a partial replacement...
PPTX
WN UNIT-II CH4_MKaruna_BapatlaEngineeringCollege.pptx
PPTX
AI-Reporting for Emerging Technologies(BS Computer Engineering)
PPTX
SE unit 1.pptx by d.y.p.akurdi aaaaaaaaaaaa
PDF
Software defined netwoks is useful to learn NFV and virtual Lans
PPTX
INTERNET OF THINGS - EMBEDDED SYSTEMS AND INTERNET OF THINGS
PDF
electrical machines course file-anna university
PPTX
ARCHITECTURE AND PROGRAMMING OF EMBEDDED SYSTEMS
PDF
MACCAFERRY GUIA GAVIONES TERRAPLENES EN ESPAÑOL
PPTX
Software-Development-Life-Cycle-SDLC.pptx
PPTX
Unit IImachinemachinetoolopeartions.pptx
Engineering Solutions for Ethical Dilemmas in Healthcare (www.kiu.ac.ug)
UNIT-I Machine Learning Essentials for 2nd years
Agentic Artificial Intelligence (Agentic AI).pptx
CELDAS DE COMBUSTIBLE TIPO MEMBRANA DE INTERCAMBIO PROTÓNICO.pdf
AIGA 012_04 Cleaning of equipment for oxygen service_reformat Jan 12.pdf
Principles of operation, construction, theory, advantages and disadvantages, ...
IAE-V2500 Engine for Airbus Family 319/320
IAE-V2500 Engine Airbus Family A319/320
ENVIRONMENTAL PROTECTION AND MANAGEMENT (18CVL756)
An investigation of the use of recycled crumb rubber as a partial replacement...
WN UNIT-II CH4_MKaruna_BapatlaEngineeringCollege.pptx
AI-Reporting for Emerging Technologies(BS Computer Engineering)
SE unit 1.pptx by d.y.p.akurdi aaaaaaaaaaaa
Software defined netwoks is useful to learn NFV and virtual Lans
INTERNET OF THINGS - EMBEDDED SYSTEMS AND INTERNET OF THINGS
electrical machines course file-anna university
ARCHITECTURE AND PROGRAMMING OF EMBEDDED SYSTEMS
MACCAFERRY GUIA GAVIONES TERRAPLENES EN ESPAÑOL
Software-Development-Life-Cycle-SDLC.pptx
Unit IImachinemachinetoolopeartions.pptx

Lecture 1: basic syntax

  • 1. Placement Preparation C++ Basics Shreyas Basarge
  • 2. Target Audience People who have no prior coding experience, didn’t take CS101 seriously but want to learn some basics of coding quickly. If you know how write a program to print fibonacci numbers, do NOT waste your time by attending this tutorial.
  • 3. Motivation 1. Most companies visiting IIT Guwahati require coding skills. 2. Everyone wants to get placed. 1 & 2 => You have to learn coding
  • 5. Hello World Your first fully functional program:
  • 6. Running C++ code Linux: 1. Install g++ 2. g++ file_name.cpp 3. ./a.out Windows: 1. Open your favorite IDE 2. Write some code 3. Click the ‘play’ button n00b: 1. Go to ideone.com 2. Write some code. Select language (C++) 3. Click on Run
  • 7. Variables Letters in which we can store numbers and other data like user input. Example: int x = 42; int y; y = x + 10; int z; cin >> z; // whatever user types in is stored in z cout << z; // whatever is in z is shown on the screen
  • 8. Variables Example: Find square of a number
  • 9. Variables Demo: 1. Take two integers from the user. 2. Find sum of their cubes. (If user’s numbers are 2 and 3, output should be 2x2x2 + 3x3x3 = 8 + 27 = 35)
  • 10. Variables Variables can store integers, real numbers and some other things. int x; // x can store an integer x = 3; float y; // y can store a real number y = 3.14;
  • 11. Variables Example: Find hypotenuse of a right angled triangle.
  • 12. if-else When you want to do different things depending on some condition. Example: Write a program to find absolute value of given integer.
  • 14. if-else if (x>3 || y<9) { … if (x>8 && y<4) { … if (x == 0) { … if (x*y >= 100) { … if (x != 7) { ...
  • 16. loops Example: display all numbers from 1 to 20
  • 17. loops Demo: Sum numbers from 1 to n.
  • 18. loops The ‘for loop’
  • 19. loops Demo: Sum of all even numbers from 1 to 100
  • 20. Examples 1. Check if number is prime 2. Print the pattern: # ## ### #### 3. Find all triplets that sum to 10
  • 21. Examples 4. Print fibonacci series 5. Find square root of x