Skip to content

Commit f716936

Browse files
committed
Added readme in different folders
1 parent 474e191 commit f716936

20 files changed

+257
-25
lines changed

Diff for: Argument_passing/Readme.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Argument Passing
2+
3+
#### Call by Value:
4+
5+
- In call by value, the function receives a copy of the value of the argument passed to it.
6+
7+
- The function operates on the copy, and any modifications made inside the function do not affect the original value in the calling code.
8+
- Changes made to the function parameters are confined within the function's scope.
9+
- This mechanism is useful when you want to work with the value of the argument without modifying it in the calling code.
10+
#### Call by Reference:
11+
12+
- In call by reference, the function receives a reference to the memory location of the argument passed to it.
13+
- Any modifications made to the parameter inside the function directly affect the original value in the calling code.
14+
- Changes made to the reference parameter are visible both inside and outside the function.
15+
- This mechanism is useful when you want to modify the value of the argument and have those modifications reflected in the calling code.
16+
#### Call by Address:
17+
18+
- In call by address, the function receives the address of the argument passed to it.
19+
- By dereferencing the address, the function can access and modify the value stored at that memory location.
20+
- Changes made to the value at the address are visible both inside and outside the function.
21+
- This mechanism is similar to call by reference but explicitly uses pointers to pass and manipulate the arguments.
22+
23+
24+
---
25+
[Next](https://github.com/Lavin-tom/cpp_programming/tree/master/)

Diff for: functions/call_by_address.cpp renamed to Argument_passing/call_by_address.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int main()
1818
cin>>n1>>n2;
1919

2020
cout<<"no before swapping"<<endl;
21-
cout<<"no1:"<<n1<<endl<<"no2:"<<n2<<endl;
21+
cout<<"no1:"<<n1<<endl<<"no2:"<<n2<<endl;
2222

2323
swap(&n1,&n2);
2424
cout<<"no after swapping"<<endl;

Diff for: Argument_passing/call_by_address_reference_value.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
// Call by Value
5+
void modifyByValue(int num) {
6+
num += 10;
7+
}
8+
9+
// Call by Reference
10+
void modifyByReference(int& num) {
11+
num += 10;
12+
}
13+
14+
// Call by Address
15+
void modifyByAddress(int* numPtr) {
16+
*numPtr += 10;
17+
}
18+
19+
int main() {
20+
int num1=5,num2=5,num3 = 5;
21+
22+
modifyByValue(num1);
23+
cout << "After call by value: " << num1 << endl;
24+
25+
modifyByReference(num2);
26+
cout << "After call by reference: " << num2 << endl;
27+
28+
modifyByAddress(&num3);
29+
cout << "After call by address: " << num3 << endl;
30+
31+
return 0;
32+
}

Diff for: functions/call_by_referance.cpp renamed to Argument_passing/call_by_referance.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int main()
1818
cin>>n1>>n2;
1919

2020
cout<<"no before swapping"<<endl;
21-
cout<<"no1:"<<n1<<endl<<"no2:"<<n2<<endl;
21+
cout<<"no1:"<<n1<<endl<<"no2:"<<n2<<endl;
2222

2323
swap(n1,n2);
2424
cout<<"no after swapping"<<endl;

Diff for: functions/call_by_value.cpp renamed to Argument_passing/call_by_value.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int main()
1818
cin>>n1>>n2;
1919

2020
cout<<"no before swapping"<<endl;
21-
cout<<"no1:"<<n1<<endl<<"no2:"<<n2<<endl;
21+
cout<<"no1:"<<n1<<endl<<"no2:"<<n2<<endl;
2222

2323
swap(n1,n2);
2424
cout<<"no after swapping"<<endl;

Diff for: Introduction-to-C++/README.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
### Introduction
2+
## C++
3+
- C++ is a general purspose programming language
4+
- It is regarded as an intermediate level language ( a combination of both high level and low level language feature)
5+
- It was developed by [`Bjarne Stroustrup`](https://en.wikipedia.org/wiki/Bjarne_Stroustrup) in 1979 at Bell Labs as an enhancement to the C language.
6+
- As a matter of fact, C++ run most of C code while C cannot run C++ code.
7+
8+
#### Procedural Oriented Programming
9+
- aka functional oriented, pgrms with functions, local and global variables.
10+
- Loops concept are not allowed
11+
- C, Pascal, Cobal etc
12+
13+
#### Structural Oriented Programming
14+
- control statements and user defined data types added along with procedural
15+
- C, Pascal, Cobal etc
16+
17+
#### Object Oriented Programming
18+
- writing instructions in the form of object instead of seqential instruction
19+
- C++, Java etc
20+
21+
#### Why C++ / Limitation of C
22+
- Not possible to create duplicate name for an existing variable in c
23+
- Not possible to allocate dma using operators
24+
- Not possible to create blocks for global variable with same name for local variable
25+
- Can't handle run time errors
26+
- Can't access global variable if local variable contain same name without pointers, another variable etc
27+
- Can't use same function defenition for different datatype
28+
29+
#### Features of C++
30+
- Encapsulation
31+
- wrapping up of data and function into a single unit
32+
- Abstraction
33+
- with the help of access specifiers (private, protected, public) we can set the visibility
34+
- Polymorphism
35+
- all functionalities are same
36+
- Inheritance
37+
- Reuse and extend the functionalities
38+
39+
#### Difference b/w C and C++
40+
41+
|C|C++|
42+
|-|-|
43+
|Procedural Oriented Language|Procedural + Object oriented Language|
44+
|Importance to Procedure|Importance to Data|
45+
|Data is not secured|Data is Secured|
46+
|Encapsulation not possible|Encapsulation possible|
47+
|Not follow Strict type check|Follow strict type check|
48+
|Not possible function overloading|Function overloading is possible|
49+
|Using of function inside structure is not possible | Use of function inside structure is possible |
50+
|Not have Exception Handling|Having exception handling|
51+
|Template is not available|Template is available|
52+
53+
```
54+
#include<iostream>
55+
using namespace std;
56+
int main()
57+
{
58+
string name;
59+
cout<<"Enter name.."<<endl;
60+
cin>>name;
61+
cout<<"Hello "<<name<<endl;
62+
}
63+
```
64+
`#include<iostream>` - flow of data from one end to another end
65+
66+
`cout` : o stream object of istream class/console output
67+
68+
`cin` : i stream object of ostream class/console input
69+
70+
`endl` : manipulator - is a function equalant to `\n`
71+
72+
`>>` extraction operator
73+
74+
`<<` insertion operator
75+
76+
77+
78+
---
79+
80+
[Next](https://github.com/Lavin-tom/cpp_programming/tree/master/Scope_resolution_operator)

Diff for: README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
# cpp_programming
2-
various cpp programming concepts with brief descriptions
1+
# C++ Programming
2+
3+
Welcome to the C++ Programming Repository! This repository is created with the aim of providing a learning resource for beginners who want to dive into the world of C++ programming. Whether you are new to programming or have some prior experience, this repository will guide you through various C++ codes and their explanations, helping you develop a strong foundation in C++.
4+
5+
## Repository Structure
6+
7+
The repository is organized into multiple directories, each focusing on a specific concept or topic in C++. You will find a variety of C++ code examples accompanied by detailed explanations to help you understand the underlying principles and techniques.
8+
9+
## Getting Started
10+
11+
If you are new to C++ or programming in general, we recommend starting with the [Introduction to C++](https://github.com/Lavin-tom/cpp_programming/tree/master/Introduction-to-C++) directory. Here, you will find introductory topics, basic syntax, and fundamental programming concepts that will lay the groundwork for your C++ journey.
12+
13+
## Start Learning C++ Today!
14+
15+
We believe that learning programming should be an enjoyable and enriching experience. With this C++ Beginner's Repository, we hope to provide you with the necessary resources to kickstart your journey into the world of C++ programming. Happy coding!
16+
17+
_Note: This repository is created for personal learning purposes and may not cover advanced or specialized topics. It is recommended to supplement your learning with additional resources as you progress in your C++ journey._

Diff for: Reference_operator/Readme.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
### Reference Operator
2+
---
3+
Used to provide alias name/duplicate name for existing varibale.
4+
5+
Syntax : `datatype &new_name = existing_name;`
6+
```
7+
example:
8+
9+
#include<iostream>
10+
using namespace std;
11+
int main()
12+
{
13+
int data=20;
14+
int &x = data;
15+
cout<<"data: "<<data<<endl;
16+
cout<<"x: "<<x<<endl;
17+
}
18+
19+
output:
20+
data: 20
21+
x: 20
22+
```
23+
24+
#### Reference to Array
25+
Syntax : `datatype (&new_array)[size] = existing_array; `
26+
27+
```
28+
example:
29+
30+
#include<iostream>
31+
using namespace std;
32+
int main()
33+
{
34+
int arr[5]={1,2,3,4,5};
35+
cout<<arr[2]<<endl;
36+
int (&new_arr)[5] = arr;
37+
cout<<new_arr[2]<<endl;
38+
}
39+
40+
output:
41+
3
42+
3
43+
```
44+
45+
#### Reference to Pointer
46+
Syntax : `datatype* (&new_variable) = existing_variable; `
47+
48+
```
49+
example:
50+
51+
#include<iostream>
52+
using namespace std;
53+
int main()
54+
{
55+
int a = 10;
56+
int *b = &a;
57+
cout<<"a:"<<a<<" "<<"b: "<<*b<<endl;
58+
int *(&c)=b;
59+
cout<<"c:"<<*c<<endl;
60+
}
61+
62+
output:
63+
a: 10 b: 10
64+
c: 10
65+
```
66+
67+
### Points
68+
- Reference variable must be initialized at the time of declaration
69+
- Seperate memory is not created for Reference
70+
- Null reference is not possible
71+
- One variable can have multiple references
72+
- Reference to reference is not possible
73+
74+
---
75+
[Next](https://github.com/Lavin-tom/cpp_programming/tree/master/Argument_passing)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: Scope_resolution_operator/Readme.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Scope Resolution operator(::)
2+
3+
To access global variable when there is local varibale with same.
4+
5+
```
6+
example:
7+
8+
#include<iostream>
9+
using namespace std;
10+
int x=10;
11+
int main()
12+
{
13+
int x=200;
14+
cout<<"local x: "<<x<<endl;
15+
cout<<"global x: "<<::x<<endl;
16+
}
17+
18+
output:
19+
local x: 200
20+
global x: 10
21+
22+
```
23+
---
24+
25+
[Next](https://github.com/Lavin-tom/cpp_programming/tree/master/Reference_operator)

Diff for: random_prgms/scope_resolution_operator.cpp renamed to Scope_resolution_operator/scope_resolution_operator.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//scope resolution operator
2-
32
#include<iostream>
43
using namespace std;
54
int x=100;

Diff for: introduction/README.md

-19
This file was deleted.

0 commit comments

Comments
 (0)