Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-aniketj authored Jun 27, 2022
1 parent 2ff8c37 commit af97f9c
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 0 deletions.
15 changes: 15 additions & 0 deletions 12 - functions/check_even_odd_using_func.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
using namespace std;
void checkNum(int); //prototype
int main() {
checkNum(12);
checkNum(5);
return 0;
}
//define
inline void checkNum(int num) {
if(num%2==0)
cout<<"Even"<<endl;
else
cout<<"Odd"<<endl;
}
11 changes: 11 additions & 0 deletions 12 - functions/func_ex1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>
using namespace std;
void fun(); //prototype
int main() {
fun();
return 0;
}
//define
void fun() {
cout<<"Hello World";
}
15 changes: 15 additions & 0 deletions 12 - functions/function_overloading_ex1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<iostream>
using namespace std;
void add(int,int);
void add(float,float);
int main() {
add(10,5); //int add
add(10.5f, 5.5f); //float add
return 0;
}
void add(int a, int b) {
cout<<a+b<<endl;
}
void add(float a, float b) {
cout<<a+b<<endl;
}
21 changes: 21 additions & 0 deletions 12 - functions/function_overloading_ex2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <iostream>
//OVERLOADING
using namespace std;
int sum(int a, int b) {
return a+b;
}
float sum(float a, float b){
return a+b;
}
int sum(int a, int b, int c) {
return a+b+c;
}
int sum(int a, int b, int c, int d) {
return a+b+c+d;
}
int main() {
cout<<sum(1,2)<<endl;
cout<<sum(1,2,3)<<endl;
cout<<sum(1,2,3,4)<<endl;
cout<<sum(1.5f, 2.25f)<<endl;
}
18 changes: 18 additions & 0 deletions 12 - functions/function_sum_square.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>
using namespace std;
void sum(int,int); //declare (prototype)
int square(int); //declare (prototype)
int main() {
int a=5,b=10;
sum(a,b);
cout<<endl<<"Square is : "<<square(5);
return 0;
}
//define
void sum(int a, int b) {
cout<<"Sum is : "<<a+b;
}
//define
int square(int x) {
return x*x;
}
9 changes: 9 additions & 0 deletions 12 - functions/inline_func_ex1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <iostream>
using namespace std;
inline void show() {
cout<<"Hello World";
}
int main() {
show();
return 0;
}
9 changes: 9 additions & 0 deletions 12 - functions/inline_func_ex2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <iostream>
using namespace std;
inline int sum(int x=0, int y=0) {
return x+y;
}
int main() {
cout<<"Sum is : "<<sum(50);
return 0;
}
13 changes: 13 additions & 0 deletions 12 - functions/min_max_func.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
#include <cmath>

//Built In Functions with is already written in header files.

using namespace std;
int main() {
// cout<<max(10, 20, 30)<<endl; (ERROR)
// we can only pass two arguments in the max(), min() func.
cout<<max(10, 20)<<endl;
cout<<min(10, 20)<<endl;
return 0;
}

0 comments on commit af97f9c

Please sign in to comment.