-
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
Pratiksha Shinde
committed
Oct 16, 2020
1 parent
9ab845a
commit e5b2154
Showing
9 changed files
with
88 additions
and
1 deletion.
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,33 @@ | ||
#include <iostream> | ||
#include <math.h> | ||
using namespace std; | ||
|
||
int count = 0, sum = 0, digit; | ||
|
||
int count_digit(int n) | ||
{ | ||
if(n >= 10) | ||
count_digit(n / 10); | ||
int digit = n%10; | ||
count++; | ||
return count; | ||
} | ||
|
||
bool each_digit(int n) | ||
{ | ||
if(n >= 10) | ||
each_digit(n / 10); | ||
int digit = n%10; | ||
sum = sum + pow(digit, count); | ||
if(sum == n) | ||
return true; | ||
return false; | ||
} | ||
|
||
int main() | ||
{ | ||
int n; | ||
cin >> n; | ||
count_digit(n); | ||
each_digit(n) ? cout << "ARMSTRONG" : cout << "NOT AN ARMSTRONG"; | ||
} |
Binary file not shown.
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,12 @@ | ||
#include <iostream> | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int cel; | ||
float F; | ||
cin >> cel; | ||
F = ((cel*1.8)+32); | ||
cout << fixed << setprecision(2) << F; | ||
} |
Binary file not shown.
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,16 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
bool perfectSquare(int n){ | ||
for (int i=1; i<=n; i++) | ||
if((i*i) == n) | ||
return true; | ||
return false; | ||
} | ||
|
||
int main() | ||
{ | ||
int n; | ||
cin >> n; | ||
perfectSquare(n) ? cout << "YES" : cout << "NO"; | ||
} |
Binary file not shown.
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
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,27 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
bool isPrime(int k) { | ||
for (int i=2; i<k; i++) | ||
if(k%i == 0) | ||
return false; | ||
return true; | ||
} | ||
|
||
int main() | ||
{ | ||
int l, u, sum=0; | ||
cin >> l; | ||
cin >> u; | ||
if(l!=0){ | ||
for (int k=(l+1); k<u; k++){ | ||
isPrime(k) ? sum = sum + k : sum = sum; | ||
} | ||
cout << sum; | ||
} else if(l==0) { | ||
for (int k=(l+1); k<u; k++){ | ||
isPrime(k) ? sum = sum + k : sum = sum; | ||
} | ||
cout << sum-1; | ||
} | ||
} |
Binary file not shown.