forked from InnogeeksOrganization/coderspree2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
5 more solutions of getting started
- Loading branch information
Showing
5 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/CountDigitsInANumber.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(int argc, char **argv){ | ||
int n,count=0; | ||
cin >> n; | ||
while(n!=0){ | ||
n=n/10; | ||
count++;} | ||
cout<<count; | ||
return 0; | ||
} |
21 changes: 21 additions & 0 deletions
21
IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/IsANumberPrime.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <iostream> | ||
using namespace std; | ||
int main(int argc, char **argv){ | ||
int t,n; | ||
cin >> t; | ||
for (int i = 0; i < t; i++){ | ||
cin >> n; | ||
int c = 2; | ||
while (c*c <= n){ | ||
if (n%c == 0) | ||
break; | ||
c++; | ||
} | ||
if (c * c > n){ | ||
cout << "prime" << endl; | ||
} | ||
else{ | ||
cout << "not prime" << endl; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/PrintAllPrimesTillN.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <iostream> | ||
using namespace std; | ||
int main(int argc, char **argv){ | ||
int low, high,i,j,c; | ||
cin >> low >> high; | ||
for(i=low;i<=high;i++) | ||
{ | ||
if(i==1||i==0) | ||
continue; | ||
c=1; | ||
for(j=2;j<=i/2;j++) | ||
{ | ||
if(i%j==0) | ||
{ | ||
c=0; | ||
break; | ||
} | ||
} | ||
if(c==1) | ||
cout<<i<<"\n"; | ||
} | ||
return 0; | ||
} |
15 changes: 15 additions & 0 deletions
15
IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/PrintFibonacciNumbersTillN.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int n,a=0,b=1,c; | ||
cin >> n; | ||
for(int i=0;i<n;i++){ | ||
cout<<a<<endl; | ||
c=a+b; | ||
a=b; | ||
b=c; | ||
} | ||
return 0; | ||
} |
13 changes: 13 additions & 0 deletions
13
IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/ReverseANumber.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(int argc, char **argv){ | ||
int n,c; | ||
cin >> n; | ||
while(n!=0){ | ||
c=n%10; | ||
cout<<c<<endl; | ||
n=n/10; | ||
} | ||
return 0; | ||
} |