diff --git a/Task 3/Q1/IIT2025262/calc.txt b/Task 3/Q1/IIT2025262/calc.txt new file mode 100644 index 0000000..b6b2bd6 --- /dev/null +++ b/Task 3/Q1/IIT2025262/calc.txt @@ -0,0 +1,2 @@ +A calculator is an tool that performs mathematical operations quickly. +It is used to make calculations faster and reduce human errors in maths and daily tasks. \ No newline at end of file diff --git a/Task 3/Q1/test.txt b/Task 3/Q1/test.txt new file mode 100644 index 0000000..2ee89e5 --- /dev/null +++ b/Task 3/Q1/test.txt @@ -0,0 +1 @@ +What is a calculator? \ No newline at end of file diff --git a/Task 3/Q2/IIT2025262/calculator.cpp b/Task 3/Q2/IIT2025262/calculator.cpp new file mode 100644 index 0000000..a6b5981 --- /dev/null +++ b/Task 3/Q2/IIT2025262/calculator.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; +int main(){ + int a,b; + cin>>a>>b; + int sum=a+b; + int diff=a-b; + int prod=a*b; + float div=a/b; + cout<<"Enter s-sum, d-diff,p-prod,d-div"; + string s; + cin>>s; + if(s=="s") + cout< +#include +using namespace std; + +int main() { + int num, originalNum, remainder; + int n = 0; + double result = 0; + + cout << "Enter a number: "; + cin >> num; + originalNum = num; + + int temp = num; + while (temp != 0) { + temp /= 10; + n++; + } + + temp = num; + while (temp != 0) { + remainder = temp % 10; + result += pow(remainder, n); + temp /= 10; + } + + if ((int)result == originalNum) + cout << originalNum << " is an Armstrong number."; + else + cout << originalNum << " is NOT an Armstrong number."; + + return 0; +} diff --git a/Task 3/Q4/palindrome.cpp b/Task 3/Q4/palindrome.cpp new file mode 100644 index 0000000..1838e3b --- /dev/null +++ b/Task 3/Q4/palindrome.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; + +int main() { + string s; + cout << "Enter a string or number: "; + cin >> s; + + int start = 0; + int end = s.length() - 1; + + bool isPalindrome = true; + + while (start < end) { + if (s[start] != s[end]) { + isPalindrome = false; + break; + } + start++; + end--; + } + + if (isPalindrome) + cout << "It is a palindrome."; + else + cout << "It is NOT a palindrome."; + + return 0; +} diff --git a/Task 3/Q5/prime b/Task 3/Q5/prime new file mode 100644 index 0000000..e69de29 diff --git a/Task 3/Q5/prime.cpp b/Task 3/Q5/prime.cpp new file mode 100644 index 0000000..88109ad --- /dev/null +++ b/Task 3/Q5/prime.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; + +int main() { + int num; + cout << "Enter a number: "; + cin >> num; + + if (num <= 1) { + cout << "Not a prime number."; + return 0; + } + + bool isPrime = true; + + for (int i = 2; i * i <= num; i++) { + if (num % i == 0) { + isPrime = false; + break; + } + } + + if (isPrime) + cout << "Prime number"; + else + cout << "Not a prime number"; + + return 0; +}