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
9 changes: 9 additions & 0 deletions Aarushi_evenOrOdd_q2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
n%2==0? cout << "Even" : cout << "Odd";
return 0;
}
Binary file added Aarushi_evenOrOdd_q2.exe
Binary file not shown.
14 changes: 14 additions & 0 deletions Aarushi_positiveOrNegative_q1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
if(n > 0)
cout << "Positive";
else if(n < 0)
cout << "Negative";
else
cout << "Zero";
return 0;
}
Binary file added Aarushi_positiveOrNegative_q1.exe
Binary file not shown.
14 changes: 14 additions & 0 deletions Aarushi_sumN_1stNaturalnos_q3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
int i=1;
int sum=0;
while(i<=n){
sum+=i;
i++;
}
cout << sum;
}
Binary file added Aarushi_sumN_1stNaturalnos_q3.exe
Binary file not shown.
Binary file added Aarushi_sumOfNNaturalno.s_q4
Binary file not shown.
15 changes: 15 additions & 0 deletions Aarushi_sumOfNNaturalno.s_q4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
int i=1;
int sum=0;
sum = n*(n+1)/2;
// while(i<=n){
// sum+=i;
// i++;
// }
cout << sum;
}
16 changes: 16 additions & 0 deletions Aarushi_sumOfnosInAGivenRange_q5.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include<iostream>
using namespace std;

int main(){
int n, m;
cin>>n >> m;

int sum = 0;
sum = m*(m+1)/2 - n*(n+1)/2 + n;
cout<<sum;
// int sum=0;
// for(int i=n; i<=m; i++){
// sum += i;
// }
// cout << sum;
}
Binary file added Aarushi_sumOfnosInAGivenRange_q5.exe
Binary file not shown.
20 changes: 20 additions & 0 deletions DAY 3/Aarushi_LeaporNot_q8.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<iostream>
using namespace std;

int main()
{
int year;

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;
}
19 changes: 19 additions & 0 deletions DAY 3/Aarushi_greatestOfThreeNumbres_q7.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>
using namespace std;

int main ()
{
int num1, num2, num3;
cin >> num1 >> num2 >> num3;

if (num1 == num2 && num2 == num3)
cout << "all are equal";
else if (num1 > num2 && num1 > num3)
cout << num1 << " is greatest";
else if (num2 > num1 && num2 > num3)
cout << num2 << " is greatest";
else
cout << num3 << " is greatest";

return 0;
}
17 changes: 17 additions & 0 deletions DAY 3/Aarushi_greatestOfTwoNumbers_q6.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
using namespace std;

int main ()
{
int num1, num2;
cin>>num1>>num2;

if (num1 == num2)
cout << "both are equal";
else if (num1 > num2)
cout << num1 << " is greater than " << num2;
else
cout << num2 << " is greater than " << num1;

return 0;
}
26 changes: 26 additions & 0 deletions DAY 3/Aarushi_primeRange_q10.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
using namespace std;

bool isPrime(int n){
if(n < 2)
return false;

for(int i = 2;i < n; i++)
{
if(n % i == 0)
return false;
}

return true;
}

int main()
{
int a, b;
cin>>a>>b;

for(int i = a; i <= b; i++)
if(isPrime(i))
cout << i << " ";

}
Binary file added DAY 3/Aarushi_primeRange_q10.exe
Binary file not shown.
35 changes: 35 additions & 0 deletions DAY 3/Aarushi_prime_q9.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
using namespace std;

bool isPrime(int n) {
if (n <= 1) {
return false;
}
if (n == 2) {
return true;
}
if (n % 2 == 0) {
return false;
}

for (int i = 2; i <= n; i += 2) {
if (n % i == 0) {
return false;
}
}

return true;
}

int main() {
int number;
cin >> number;

if (isPrime(number)) {
cout << number << " is a prime number." << endl;
} else {
cout << number << " is not a prime number." << endl;
}

return 0;
}
20 changes: 20 additions & 0 deletions DAY 3/Aarushi_reverse_q12.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;

int main ()
{
int n, rev = 0, r;
cin>>n;

while(n != 0)
{
r = n % 10;
rev = rev * 10 + r;
n /= 10;
};

//output
cout <<"Reversed Number: "<<rev;

return 0;
}
17 changes: 17 additions & 0 deletions DAY 3/Aarushi_sumOfDigits_q11.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<iostream>
using namespace std;

int main()
{
int n;
cin>>n;
int sum = 0;
while(n > 0)
{
int digit = n % 10;
sum+= digit;
n = n / 10;
}
cout<<sum;

}