Skip to content

Commit af97f9c

Browse files
authored
Add files via upload
1 parent 2ff8c37 commit af97f9c

8 files changed

+111
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <iostream>
2+
using namespace std;
3+
void checkNum(int); //prototype
4+
int main() {
5+
checkNum(12);
6+
checkNum(5);
7+
return 0;
8+
}
9+
//define
10+
inline void checkNum(int num) {
11+
if(num%2==0)
12+
cout<<"Even"<<endl;
13+
else
14+
cout<<"Odd"<<endl;
15+
}

12 - functions/func_ex1.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <iostream>
2+
using namespace std;
3+
void fun(); //prototype
4+
int main() {
5+
fun();
6+
return 0;
7+
}
8+
//define
9+
void fun() {
10+
cout<<"Hello World";
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include<iostream>
2+
using namespace std;
3+
void add(int,int);
4+
void add(float,float);
5+
int main() {
6+
add(10,5); //int add
7+
add(10.5f, 5.5f); //float add
8+
return 0;
9+
}
10+
void add(int a, int b) {
11+
cout<<a+b<<endl;
12+
}
13+
void add(float a, float b) {
14+
cout<<a+b<<endl;
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <iostream>
2+
//OVERLOADING
3+
using namespace std;
4+
int sum(int a, int b) {
5+
return a+b;
6+
}
7+
float sum(float a, float b){
8+
return a+b;
9+
}
10+
int sum(int a, int b, int c) {
11+
return a+b+c;
12+
}
13+
int sum(int a, int b, int c, int d) {
14+
return a+b+c+d;
15+
}
16+
int main() {
17+
cout<<sum(1,2)<<endl;
18+
cout<<sum(1,2,3)<<endl;
19+
cout<<sum(1,2,3,4)<<endl;
20+
cout<<sum(1.5f, 2.25f)<<endl;
21+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
using namespace std;
3+
void sum(int,int); //declare (prototype)
4+
int square(int); //declare (prototype)
5+
int main() {
6+
int a=5,b=10;
7+
sum(a,b);
8+
cout<<endl<<"Square is : "<<square(5);
9+
return 0;
10+
}
11+
//define
12+
void sum(int a, int b) {
13+
cout<<"Sum is : "<<a+b;
14+
}
15+
//define
16+
int square(int x) {
17+
return x*x;
18+
}

12 - functions/inline_func_ex1.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <iostream>
2+
using namespace std;
3+
inline void show() {
4+
cout<<"Hello World";
5+
}
6+
int main() {
7+
show();
8+
return 0;
9+
}

12 - functions/inline_func_ex2.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <iostream>
2+
using namespace std;
3+
inline int sum(int x=0, int y=0) {
4+
return x+y;
5+
}
6+
int main() {
7+
cout<<"Sum is : "<<sum(50);
8+
return 0;
9+
}

12 - functions/min_max_func.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
#include <cmath>
3+
4+
//Built In Functions with is already written in header files.
5+
6+
using namespace std;
7+
int main() {
8+
// cout<<max(10, 20, 30)<<endl; (ERROR)
9+
// we can only pass two arguments in the max(), min() func.
10+
cout<<max(10, 20)<<endl;
11+
cout<<min(10, 20)<<endl;
12+
return 0;
13+
}

0 commit comments

Comments
 (0)