-
Notifications
You must be signed in to change notification settings - Fork 0
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
844f881
commit eeac979
Showing
2 changed files
with
91 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,87 @@ | ||
//functions in depth | ||
//why func are important | ||
//how to declare functions | ||
//how to call a function | ||
//scope of a variables | ||
//function calll by value | ||
//function call y refrence | ||
//default parameter value | ||
#include<iostream> | ||
#include<cmath> | ||
using namespace std; | ||
int GlobalVariable=20; //these are accesable in all place f program | ||
int squareNumber(int n) //find the sqaue of n natural number | ||
{ | ||
return n*n; | ||
} | ||
double area(int radius) //Area | ||
{ | ||
return 3.14 * (radius*radius); | ||
} | ||
double circumstance(int radius) | ||
{ //Area of ircumstance | ||
return 2*3.14*(radius); | ||
} | ||
void EligibilityVote(int age) //chek eligibility of the vote | ||
{ | ||
if (age>18) | ||
{ | ||
cout<<"Yes you can vote"<<endl; | ||
} | ||
else | ||
{ | ||
cout<<"Sorry you cant.."<<endl; | ||
} | ||
} | ||
int CheckOdd(int num) //odd nummber between two pints | ||
{ | ||
if (num%2 !=0) | ||
{ | ||
return num; | ||
} | ||
|
||
} | ||
bool checkPrime(int num) //check the prime nmber between two point | ||
{ | ||
for (int i=2;i<=sqrt(num);i++) | ||
{ | ||
if (num%i==0) | ||
{ | ||
return false; | ||
} | ||
} | ||
return true; | ||
|
||
} | ||
int main() //Main function | ||
{ | ||
for (int i =1;i<= 5;i++) | ||
{ | ||
cout<<squareNumber(i)<<" "; | ||
} | ||
cout<<endl; | ||
int val=3; //loal variable which canot acess outide fromthe function | ||
double result=area(val); | ||
float result_=circumstance(val); | ||
cout<<"The area of result is:"<<result<<endl; | ||
cout<<"The circumstance of result is:"<<result_<<endl; | ||
int age=19; | ||
EligibilityVote(age); | ||
int num1=1; | ||
int num2=10; | ||
for (int i=num1;i<=num2;i++) | ||
{ | ||
cout<<CheckOdd(i)<<endl; | ||
} | ||
cout<<endl; | ||
cout<<endl; | ||
int prime1=2; | ||
int prime2=40; | ||
for (int i=prime1;i<=prime2;i++) | ||
{ | ||
if (checkPrime(i)) | ||
{ | ||
cout<<i<<" "; | ||
} | ||
} | ||
} |
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,4 @@ | ||
#include<iostream> | ||
using namespae std; | ||
int main() | ||
{ |