-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ff8c37
commit af97f9c
Showing
8 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |