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 17, 2020
1 parent e5b2154 commit dfa1713
Show file tree
Hide file tree
Showing 33 changed files with 358 additions and 1 deletion.
74 changes: 73 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,78 @@
{
"files.associations": {
"iostream": "cpp",
"ostream": "cpp"
"ostream": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"csetjmp": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cuchar": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"scoped_allocator": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
}
}
24 changes: 24 additions & 0 deletions Binary_to_Decimal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
#include <math.h>
#include <string>
#include <bits/stdc++.h>
using namespace std;

int main()
{
string str, str2;
int j = 0, sum =0, i=0;
cin >> str;
int len = str.length();
reverse(str.begin(), str.end());
while(j!=(len) && i!=len) {
str2 = str[i];
stringstream convert(str2);
int x;
convert >> x;
sum = sum + (x*pow(2,j));
j++;
i++;
}
cout << sum;
}
Binary file added Binary_to_Decimal.exe
Binary file not shown.
23 changes: 23 additions & 0 deletions Binary_to_Octal_other_Method.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;

int main()
{
int binary;
cin >> binary;
int i = 0, octal = 0, decimal = 0;
while(binary!=0){
decimal = decimal + ((binary%10)*pow(2, i));
i++;
binary = int(binary/10);
}
i = 1;
while(decimal!=0){
octal = octal + ((decimal%8)*i);
decimal = int(decimal/8);
i = i*10;
}
cout << octal;
}
Binary file added Binary_to_Octal_other_Method.exe
Binary file not shown.
11 changes: 11 additions & 0 deletions Circumference_of_Circle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
float r, circumference;
cin >> r;
circumference = (2*3.14*r);
cout << fixed << setprecision(2) << circumference;
}
Binary file added Circumference_of_Circle.exe
Binary file not shown.
18 changes: 18 additions & 0 deletions Decimal_to_Octal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;

int main()
{
int decimal;
cin >> decimal;
int i, octal = 0;
i = 1;
while(decimal!=0){
octal = octal + ((decimal%8)*i);
decimal = int(decimal/8);
i = i*10;
}
cout << octal;
}
Binary file added Decimal_to_Octal.exe
Binary file not shown.
20 changes: 20 additions & 0 deletions Fibonacci_Series.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;

int main()
{
int n, t1=0, t2=1, tn;
cin >> n;
for (int i=0; i<n; i++) {
if(i==0) {
tn = t1;
} else if(i==1) {
tn = t2;
} else {
tn = t1+t2;
t1 = t2;
t2 = tn;
}
cout << tn << " ";
}
}
Binary file added Fibonacci_Series.exe
Binary file not shown.
17 changes: 17 additions & 0 deletions Greatest_Of_Three_Numbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
using namespace std;

int main()
{
int n1, n2, n3;
cin >> n1;
cin >> n2;
cin >> n3;
if(n1>=n2 && n1>=n3){
cout << n1;
} else if(n2>=n1 && n2>=n3) {
cout << n2;
} else{
cout << n3;
}
}
Binary file added Greatest_Of_Three_Numbers.exe
Binary file not shown.
Binary file modified Length_of_String.exe
Binary file not shown.
20 changes: 20 additions & 0 deletions Nth_Fibonacci_Number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;

int main()
{
int n, t1=0, t2=1, tn;
cin >> n;
for (int i=0; i<n; i++) {
if(i==0) {
tn = t1;
} else if(i==1) {
tn = t2;
} else {
tn = t1+t2;
t1 = t2;
t2 = tn;
}
}
cout << tn << " ";
}
Binary file added Nth_Fibonacci_Number.exe
Binary file not shown.
19 changes: 19 additions & 0 deletions Palindrome.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>
using namespace std;

bool palindrome(string str) {
int len = str.length();
int mid = len/2;
for (int i=0; i<mid; i++)
for (int j=len; j>mid; j--)
if(str[i]==str[j])
return true;
return false;
}

int main()
{
std::string str;
std::getline(std::cin, str);
palindrome(str) ? cout << "Palindrome" : cout << "Not a Palindrome";
}
Binary file added Palindrome.exe
Binary file not shown.
19 changes: 19 additions & 0 deletions Palindrome_Other_Method.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;

bool palindrome(string str1, string str2) {
if(str1 == str2)
return true;
return false;
}

int main()
{
std::string str1, str2;
std::getline(std::cin, str1);
str2 = str1;
reverse(str2.begin(), str2.end());
palindrome(str1, str2) ? cout << "Palindrome" : cout << "Not a Palindrome";
}
Binary file added Palindrome_Other_Method.exe
Binary file not shown.
15 changes: 15 additions & 0 deletions Reverse_Number_other_Logic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
using namespace std;

int main()
{
int n, reverse = 0, remainder;
cin >> n;
while(n != 0)
{
remainder = n % 10;
reverse = (reverse*10) + remainder;
n = n / 10;
}
cout << reverse;
}
Binary file added Reverse_Number_other_Logic.exe
Binary file not shown.
20 changes: 20 additions & 0 deletions Reverse_the_given_Number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;

int main()
{
string str, str2;
int i;
cin >> str;
int len = str.length();
reverse(str.begin(), str.end());
if(str[0]=='0'){
for(int j=1; j<=len; j++){
cout << str[j];
}
} else {
cout << str;
}
}
Binary file added Reverse_the_given_Number.exe
Binary file not shown.
17 changes: 17 additions & 0 deletions Roots_of_Quadratic_Equation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
int a, b, c;
float root1, root2, diff;
cin >> a;
cin >> b;
cin >> c;
diff = b*b-4*a*c;
root1 = (-b+sqrt(diff))/(2*a);
root2 = (-b-sqrt(diff))/(2*a);
cout << "root1 = " << fixed << setprecision(2) << root1 << " " << "root2 = " << fixed << setprecision(2) << root2;
}
Binary file added Roots_of_Quadratic_Equation.exe
Binary file not shown.
21 changes: 21 additions & 0 deletions Second_Greatest_of_Three_Numbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <iostream>
using namespace std;

int main()
{
int n1, n2, n3;
cin >> n1;
cin >> n2;
cin >> n3;
if((n1>n2 && n1<n3) || (n1<n2 && n1>n3) || (n1==n2 && n1<n3)){
cout << n1;
} else if((n2>n1 && n2<n3) || (n2<=n1 && n2>n3) || (n1==n3 && n1>n2)) {
cout << n2;
}
else if(n1==n2 && n1>n3) {
cout << n3;
}
else{
cout << n3;
}
}
Binary file added Second_Greatest_of_Three_Numbers.exe
Binary file not shown.
Binary file modified Simple_Interest.exe
Binary file not shown.
19 changes: 19 additions & 0 deletions String_Palindrome.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;

bool palindrome(string str1, string str2) {
if(str1 == str2)
return true;
return false;
}

int main()
{
std::string str1, str2;
std::getline(std::cin, str1);
str2 = str1;
reverse(str2.begin(), str2.end());
palindrome(str1, str2) ? cout << str1 << " is a palindrome" : cout << str1 << " is not a palindrome";
}
Binary file added String_Palindrome.exe
Binary file not shown.
22 changes: 22 additions & 0 deletions String_Reverse_using_Recursion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
#include <string>
using namespace std;

void reverse(string str)
{
int len = str.length();
if(len==1)
cout<<str;
else
{
cout << str[len-1];
reverse(str.substr(0, len - 1));
}
}

int main()
{
string str;
getline(cin, str);
reverse(str);
}
Binary file added String_Reverse_using_Recursion.exe
Binary file not shown.

0 comments on commit dfa1713

Please sign in to comment.