0% found this document useful (0 votes)
26 views

Basics of Programming in C++

This document provides an overview of basic programming concepts in C++ including data types, variables, strings, conditional statements, loops, operators, arrays, and functions. It introduces first programs in C++ and discusses important data types like int, float, bool and char. It also covers if-else statements, for loops, while loops, logical operators and how arrays can be defined as a collection of elements of the same type stored in contiguous memory locations. Finally, it gives the syntax for defining functions in C++.

Uploaded by

Vishwajeet Awale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Basics of Programming in C++

This document provides an overview of basic programming concepts in C++ including data types, variables, strings, conditional statements, loops, operators, arrays, and functions. It introduces first programs in C++ and discusses important data types like int, float, bool and char. It also covers if-else statements, for loops, while loops, logical operators and how arrays can be defined as a collection of elements of the same type stored in contiguous memory locations. Finally, it gives the syntax for defining functions in C++.

Uploaded by

Vishwajeet Awale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

DSA FOR ALL

LECTURE : 2
Basics of Programming C++.
TABLE OF CONTENTS

01 First Program in C++

02 Data Types And Variables and Strings

03 Condition Statements
04 Loops
05 Operators
06 Arrays and Problems Solving
FIRST PROGRAM IN C++

#include<bits/stdc++.h>
using namespace std;
Header Files
int main() {
cout<<“Hello World”;
return 0; Main() Function
}

Output : Hello World


Data-Types And Variable

Important Data-Types Are:

1.) int
2.) long long int
3.) float
4.) double
5.) bool (Boolean)
6.) char

Variable are used with datatypes, it is generally


used to store values.

Syntax of a Variable :

DataType varname;

Ex : int data;
String String str = “Hello”;

String are defined as group of characters.

It is used to represent text in a program and change it.


If-else Statement
Syntax :
If(condition)
{
statement;
}
else if(condition)
{
}
else
{
}

If else are two conditional statements, which are generally used when we want to
run the code based on some condition.
For Loop
Syntax :
for(initialization;condition;updation){

Ex:
for(int i=0;i<10;i++){
cout<<“hello”;
}

For loops are used to repeat the execution of the code, instead of repeating the code
again and again.
While Loop
Syntax :
while(condition){
Body;
}
Ex:
While(num<10)
{
cout<<num;
num+=1;
}

While loops are used when we don’t know the exact number of times the loop
should repeat.it repeats the statement or body till the condition is true.
Operators
And : &
or : |

xor : ^
Not : !

Operators are defined to make some conditions .


Arrays

#include<bits/stdc++.h>
using namespace std;

int main() {
cout<<“Hello World”;
return 0;
Arrays can be defined
} as group or collection of elements of the same type.
Array elements are stored at contiguous memory locations.
Syntax for Array Declaration
Datatype arr_name[no. of elements];
Functions
Syntax :
Return-type name(arguments){
body;
}

Functions is a group or collection of statements that are designed to perform


specific tasks.

You might also like