Skip to content
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
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/nologo",
"/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
16 changes: 16 additions & 0 deletions PS-Sprint-1/1_even_odd_numbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <iostream>
using namespace std;

int main() {
int n;

cout << "Enter an integer: ";
cin >> n;

if ( n % 2 == 0)
cout << n << " is even.";
else
cout << n << " is odd.";

return 0;
}
Binary file added PS-Sprint-1/1_even_odd_numbers.exe
Binary file not shown.
31 changes: 31 additions & 0 deletions PS-Sprint-1/2_checking_for_prime_numbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <iostream>
using namespace std;

int main() {

int i, n;
bool is_prime = true;

cout << "Enter a positive integer: ";
cin >> n;

// 0 and 1 are not prime numbers
if (n == 0 || n == 1) {
is_prime = false;
}

// loop to check if n is prime
for (i = 2; i <= n/2; ++i) {
if (n % i == 0) {
is_prime = false;
break;
}
}

if (is_prime)
cout << n << " is a prime number";
else
cout << n << " is not a prime number";

return 0;
}
Binary file added PS-Sprint-1/2_checking_for_prime_numbers.exe
Binary file not shown.
21 changes: 21 additions & 0 deletions PS-Sprint-1/3_validating_leap_years.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <bits/stdc++.h>
using namespace std;

int main()
{
int year;

cout<<"Enter a year \n";
cin>>year;

if(year % 400 == 0)
cout << year << " is a Leap Year";

else if(year % 4 == 0 && year % 100 != 0)
cout << year << " is a Leap Year";

else
cout << year << " is not a Leap Year";

return 0;
}
Binary file added PS-Sprint-1/3_validating_leap_years.exe
Binary file not shown.
26 changes: 26 additions & 0 deletions PS-Sprint-1/4_calculating_armstrong_numbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
using namespace std;

int main() {
int num, originalNum, remainder, result = 0;
cout << "Enter a three-digit integer: ";
cin >> num;
originalNum = num;

while (originalNum != 0) {
// remainder contains the last digit
remainder = originalNum % 10;

result += remainder * remainder * remainder;

// removing last digit from the original number
originalNum /= 10;
}

if (result == num)
cout << num << " is an Armstrong number.";
else
cout << num << " is not an Armstrong number.";

return 0;
}
Binary file added PS-Sprint-1/4_calculating_armstrong_numbers.exe
Binary file not shown.
22 changes: 22 additions & 0 deletions PS-Sprint-1/5_fibonacci_series.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
using namespace std;

int main() {
int t1 = 0, t2 = 1, nextTerm = 0, n;

cout << "Enter a positive number: ";
cin >> n;

// displays the first two terms which is always 0 and 1
cout << "Fibonacci Series: " << t1 << ", " << t2 << ", ";

nextTerm = t1 + t2;

while(nextTerm <= n) {
cout << nextTerm << ", ";
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
}
return 0;
}
Binary file added PS-Sprint-1/5_fibonacci_series.exe
Binary file not shown.