Skip to content

Commit

Permalink
TCS NQT
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratiksha Shinde committed Oct 16, 2020
1 parent 9ab845a commit e5b2154
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 1 deletion.
33 changes: 33 additions & 0 deletions Armstrong_Number_Or_Not.cpp
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 added Armstrong_Number_Or_Not.exe
Binary file not shown.
12 changes: 12 additions & 0 deletions Centigrade_to_Fahrenheit.cpp
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 added Centigrade_to_Fahrenheit.exe
Binary file not shown.
16 changes: 16 additions & 0 deletions Perfect_Square.cpp
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 added Perfect_Square.exe
Binary file not shown.
1 change: 0 additions & 1 deletion Strong_Number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ bool print_each_digit(int x)
print_each_digit(x / 10);

int digit = x%10;
//cout << digit << endl;
sum = sum + fact(digit);
if(sum == x) {
return true;
Expand Down
27 changes: 27 additions & 0 deletions Sum_Of_Prime_Numbers.cpp
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 added Sum_Of_Prime_Numbers.exe
Binary file not shown.

0 comments on commit e5b2154

Please sign in to comment.