Skip to content

Commit

Permalink
MoreOfGettingStarted
Browse files Browse the repository at this point in the history
5 more solutions of getting started
  • Loading branch information
tansin25 committed Oct 4, 2022
1 parent 1ff524a commit 19f75d5
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
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;
}
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;
}
}
}
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;
}
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;
}
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;
}

0 comments on commit 19f75d5

Please sign in to comment.