Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Pull Request #190

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CodeForWin/1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;


int cube( int a)
{
int ans = a*a*a;
return ans;
}

int main()
{
int a;
cin>>a;

cout << "Cube of "<<a<<" = "<<cube(a);


return 0;
}
33 changes: 33 additions & 0 deletions CodeForWin/2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <iostream>
using namespace std;


int diameter( int a)
{
int ans1 = a*2;
return ans1;
}

float circumference( int a)
{
float ans2 = 2*a*3.14;
return ans2;
}

float area( int a)
{
float ans3 = 3.14*a*a;
return ans3;
}

int main()
{
int a;
cin>>a;

cout << "Diameter of circle with radius "<<a<<" = "<<diameter(a)<<endl;
cout << "Circumference of circle with radius "<<a<<" = "<<circumference(a)<<endl;
cout << "Area of circle with radius "<<a<<" = "<<area(a)<<endl;

return 0;
}
43 changes: 43 additions & 0 deletions CodeForWin/3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <iostream>
using namespace std;


int maximum( int a, int b)
{
int mx;
if(b>a)
{
mx = b;
}

else
mx = a;

return mx;
}

int minimum( int a, int b)
{
int min;
if(b<a)
{
min = b;
}

else
min = a;

return min;
}


int main()
{
int a,b;
cin>>a>>b;

cout << "Maximum of "<<a<<" and "<<b<<" = "<<maximum(a,b)<<endl;
cout << "Minimum of "<<a<<" and "<<b<<" = "<<minimum(a,b)<<endl;

return 0;
}
27 changes: 27 additions & 0 deletions CodeForWin/4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
using namespace std;


void even_odd( int a)
{
int ans;
if(a%2==0)
{
cout<<a<<" is an even number"<<endl;
}

else
cout<<a<<" is an odd number"<<endl;

}

int main()
{
int a;
cin>>a;

even_odd(a);


return 0;
}
80 changes: 80 additions & 0 deletions CodeForWin/5.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include <iostream>
#include <cmath>
using namespace std;


void prime( int a)
{
bool check = 0;

for( int i=2; i<=sqrt(a); i++)
{
if(a%i==0)
{
cout<<a<<" is not a prime number"<<endl;
check = 1;
break;
}
}

if(check==0)
{
cout<<a<<" is a prime number"<<endl;
}
}


void armstrong( int a)
{
int y=0, original = a;


while(a>0)
{
int last = a%10;
y= y+ (last*last*last);
a=a/10;
}

if( y==original)
{
cout<<original<<" an armstrong number "<<endl;
}

else
cout<<original<<" not an armstrong number "<<endl;

}

void perfect( int a)
{
int count =0;
for( int i=1; i<a; i++)
{
if( a%i == 0)
{
count = count + i;
}
}

if( count==a)
{
cout<<a<<" is a perfect number"<<endl;
}

else
cout<<a<<" is not a perfect number"<<endl;
}


int main()
{
int a;
cin>>a;

prime(a);
armstrong(a);
perfect(a);

return 0;
}
42 changes: 42 additions & 0 deletions CodeForWin/6.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <iostream>
#include <cmath>
using namespace std;



int isprime( int a)
{
for( int i=2; i<=a/2; i++ )
{
if( a%i==0)
{
return 0;
}
}
return 1;

}


void prime( int a, int b)
{
while( a<=b)
{
if( isprime(a))
{
cout<<a<<endl;
}
a++;
}
}


int main()
{
int a,b;
cin>>a>>b;

prime(a , b);

return 0;
}
53 changes: 53 additions & 0 deletions CodeForWin/7.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <iostream>
#include <cmath>
using namespace std;


int isstrong( int a)
{
int fact = 1, original =a, sum=0;

while( a>0)
{
int last = a%10;

for( int i=1; i<=last; i++)
{
fact = fact*i;
}

sum = sum + fact;
a = a/10;
}

if( sum == original)
{
return 1;
}

return 0;
}

void strong( int a, int b)
{
while( a<= b)
{
if(isstrong(a))
{
cout<<a<<endl;
}

a++;
}

}

int main()
{
int a,b;
cin>>a>>b;

strong(a,b);

return 0;
}
20 changes: 20 additions & 0 deletions KhushiPM/1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;


int cube( int a)
{
int ans = a*a*a;
return ans;
}

int main()
{
int a;
cin>>a;

cout << "Cube of "<<a<<" = "<<cube(a);


return 0;
}
33 changes: 33 additions & 0 deletions KhushiPM/2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <iostream>
using namespace std;


int diameter( int a)
{
int ans1 = a*2;
return ans1;
}

float circumference( int a)
{
float ans2 = 2*a*3.14;
return ans2;
}

float area( int a)
{
float ans3 = 3.14*a*a;
return ans3;
}

int main()
{
int a;
cin>>a;

cout << "Diameter of circle with radius "<<a<<" = "<<diameter(a)<<endl;
cout << "Circumference of circle with radius "<<a<<" = "<<circumference(a)<<endl;
cout << "Area of circle with radius "<<a<<" = "<<area(a)<<endl;

return 0;
}
Loading