diff --git a/IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/CountDigitsInANumber.cpp b/IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/CountDigitsInANumber.cpp new file mode 100644 index 00000000..4a9ef246 --- /dev/null +++ b/IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/CountDigitsInANumber.cpp @@ -0,0 +1,12 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n,count=0; + cin >> n; + while(n!=0){ + n=n/10; + count++;} + cout< +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; + } + } +} \ No newline at end of file diff --git a/IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/PrintAllPrimesTillN.cpp b/IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/PrintAllPrimesTillN.cpp new file mode 100644 index 00000000..465ca7ad --- /dev/null +++ b/IOT/tansin25_TanmaySingh_2125csit1072_2/GettingStarted/PrintAllPrimesTillN.cpp @@ -0,0 +1,23 @@ +#include +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< +using namespace std; + +int main(int argc, char **argv) +{ + int n,a=0,b=1,c; + cin >> n; + for(int i=0;i +using namespace std; + +int main(int argc, char **argv){ + int n,c; + cin >> n; + while(n!=0){ + c=n%10; + cout<