From b7a46c9431e065c5712379396fb46f30854efcb2 Mon Sep 17 00:00:00 2001 From: Nivedita-R Date: Thu, 29 Sep 2022 18:24:19 +0530 Subject: [PATCH 1/5] Create Hello.txt Create Hello.txt --- .../Getting Started/Hello.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Getting Started/Hello.txt diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Getting Started/Hello.txt b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Getting Started/Hello.txt new file mode 100644 index 00000000..46b8938e --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Getting Started/Hello.txt @@ -0,0 +1 @@ +Nivedita Rai From 01fce850727e58436e6a47d7f144d7c895745b46 Mon Sep 17 00:00:00 2001 From: Nivedita-R Date: Tue, 4 Oct 2022 00:07:16 +0530 Subject: [PATCH 2/5] module1 my first module of programs --- .../Getting Started/Hello.txt | 1 - .../GettingStarted/CountDigitsInANumber.cpp | 18 +++++++++++ .../GettingStarted/GradingSystem.cpp | 22 +++++++++++++ .../GettingStarted/IsANumberPrime.cpp | 31 +++++++++++++++++++ .../GettingStarted/PrintAllPrimesTillN.cpp | 19 ++++++++++++ .../PrintFibonacciNumbersTillN.cpp | 19 ++++++++++++ .../GettingStarted/PrintZ.cpp | 29 +++++++++++++++++ 7 files changed, 138 insertions(+), 1 deletion(-) delete mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Getting Started/Hello.txt create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/CountDigitsInANumber.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/GradingSystem.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/IsANumberPrime.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/PrintAllPrimesTillN.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/PrintFibonacciNumbersTillN.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/PrintZ.cpp diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Getting Started/Hello.txt b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Getting Started/Hello.txt deleted file mode 100644 index 46b8938e..00000000 --- a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Getting Started/Hello.txt +++ /dev/null @@ -1 +0,0 @@ -Nivedita Rai diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/CountDigitsInANumber.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/CountDigitsInANumber.cpp new file mode 100644 index 00000000..515488bd --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/CountDigitsInANumber.cpp @@ -0,0 +1,18 @@ +#include +#include +using namespace std; + +int main(){ + int n; + cin >> n; + if(n>=1 && n<=pow(10.0,9.0)){ + int d=0; + while(n!=0) + { + n=n/10; + d++; + } + cout< + +using namespace std; + +int main() +{ + int a; + cin>>a; + if(a>90) + cout<<"excellent"<80) + cout<<"good"<70 && a<=80) + cout<<"fair"<60 && a<=70) + cout<<"meets expectations"< +#include +using namespace std; +int main(){ + int t,i,j,n,c; + cin >> t; + if(t>=1 && t<=10000) + { + for (i=0;i>n; + if(n>=2 && n<=pow(10,9)) + { + + for(j=1;j<=n;j++) + { + if(n%j==0) + c++; + + } + if(c==2) + cout<<"prime"< +#include +using namespace std; +int main(int argc, char **argv){ + int low, high, i,j,c=0; + cin >> low >> high; + for(i=low;i<=high;i++) + {c=0; + for(j=2;j<=sqrt(i);j++) + { + if(i%j==0) + c++; + } + if(c==0) + cout< +using namespace std; + +int main(int argc, char **argv) +{ + int n,c; + cin >> n; + int a=0,b=1; + cout< + +using namespace std; + +int main() +{ + int i,j,k; + for(i=0;i<5;i++) + { + for(j=4;j>=0;j--) + { + if(i==0 || i==4) + cout<<"*"; + else + { + if(i==j) + cout<<"*"; + else + cout<<" "; + } + + } + cout< Date: Thu, 13 Oct 2022 00:29:55 +0530 Subject: [PATCH 3/5] more from getting started some ques from getting started --- .../GettingStarted/DigitsOfANumber.cpp | 25 +++++++++++++ .../GettingStarted/GcdAndLcm.cpp | 22 ++++++++++++ .../GettingStarted/InverseOfANumber.cpp | 35 +++++++++++++++++++ .../GettingStarted/ReverseANumber.cpp | 18 ++++++++++ 4 files changed, 100 insertions(+) create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/DigitsOfANumber.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/GcdAndLcm.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/InverseOfANumber.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/ReverseANumber.cpp diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/DigitsOfANumber.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/DigitsOfANumber.cpp new file mode 100644 index 00000000..358f74fd --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/DigitsOfANumber.cpp @@ -0,0 +1,25 @@ +#include +#include +using namespace std; + +int main(int argc, char **argv){ + int n,c=0; + cin >> n; + int m,i,j; + m=n; + while(n != 0) + { + c++; + n = n / 10; + } + c = c - 1; + i = pow (10.0,c); + while(i!=0) + { + cout << m/i << endl; + m = m % i; + i = i / 10; + + } + +} diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/GcdAndLcm.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/GcdAndLcm.cpp new file mode 100644 index 00000000..3e101fb5 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/GcdAndLcm.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; + +int main() +{ + int n1, n2, i; + int gcd = 1, lcm = 1; + + + cin >> n1 >> n2; + for ( i = 1; i < 1000; i++) + { if ((n1 % i == 0) && (n2 % i == 0)) + { + gcd = i; + } + } + + lcm = (n1 * n2) / gcd; + cout << gcd << endl << lcm < +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; + int d = 0 , lo,m,i,j,t,k=0; + int *arr,*arr2; + m = n; + while(m != 0) + { + d++; + m = m/10; + } + arr = (int*)malloc(d*sizeof(int)); + arr2 = (int*)malloc(d*sizeof(int)); + m = n; + while(m!=0) + { + arr[k] = m % 10; + m = m / 10; + k++; + } + + for(j=0;j=0;j--) + cout << arr2[j] ; + +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/ReverseANumber.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/ReverseANumber.cpp new file mode 100644 index 00000000..91ad62df --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/GettingStarted/ReverseANumber.cpp @@ -0,0 +1,18 @@ +#include +#include +using namespace std; + +int main(){ + int n; + cin >> n; + + int d; + while(n != 0) + { + d = n % 10; + cout << d << endl; + n = n / 10; + } + return 0; + +} \ No newline at end of file From 946325f05b9b8cbe77a2623cbf96c40713f5ec9d Mon Sep 17 00:00:00 2001 From: Nivedita-R Date: Sat, 15 Oct 2022 03:33:21 +0530 Subject: [PATCH 4/5] Module Patterns completed module patterns. --- .../Patterns/Pattern1.cpp | 22 +++++++ .../Patterns/Pattern10.cpp | 42 ++++++++++++ .../Patterns/Pattern11.cpp | 16 +++++ .../Patterns/Pattern12.cpp | 27 ++++++++ .../Patterns/Pattern13.cpp | 22 +++++++ .../Patterns/Pattern14.cpp | 12 ++++ .../Patterns/Pattern15.cpp | 39 +++++++++++ .../Patterns/Pattern16.cpp | 41 ++++++++++++ .../Patterns/Pattern17.cpp | 36 +++++++++++ .../Patterns/Pattern18.cpp | 36 +++++++++++ .../Patterns/Pattern19.cpp | 64 +++++++++++++++++++ .../Patterns/Pattern2.cpp | 22 +++++++ .../Patterns/Pattern20.cpp | 27 ++++++++ .../Patterns/Pattern3.cpp | 24 +++++++ .../Patterns/Pattern4.cpp | 24 +++++++ .../Patterns/Pattern5.cpp | 31 +++++++++ .../Patterns/Pattern6.cpp | 35 ++++++++++ .../Patterns/Pattern7.cpp | 22 +++++++ .../Patterns/Pattern8.cpp | 22 +++++++ .../Patterns/Pattern9.cpp | 23 +++++++ 20 files changed, 587 insertions(+) create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern1.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern10.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern11.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern12.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern13.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern14.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern15.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern16.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern17.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern18.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern19.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern2.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern20.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern3.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern4.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern5.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern6.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern7.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern8.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern9.cpp diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern1.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern1.cpp new file mode 100644 index 00000000..e674dac1 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern1.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i +using namespace std; +int main(int argc, char** argv){ + int n; + cin >> n; + int s1 = n / 2; + int s2 = -1; + + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= s1; j++) + { + cout << "\t"; + } + cout << "*\t"; + + for (int j = 1; j <= s2; j++) + { + cout << "\t"; + } + if ( i > 1 && i < n) + { + cout << "*\t"; + } + + if (i <= n / 2) + { + s1--; + s2 = s2 + 2; + } + else + { + s1++; + s2 = s2 - 2; + } + cout<<"\n"; + } + } + + + + \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern11.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern11.cpp new file mode 100644 index 00000000..e31115db --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern11.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n,i,j,k=1; + cin >> n; + for(i=1;i<=n;i++) + { + for(j=1;j<=i;j++) + { + cout<< k<<"\t"; + k++; + } + cout< +using namespace std; + +int main(int argc, char **argv){ + int n,*arr; + cin >> n; + arr=(int*)malloc((n*n)*sizeof(int)); + int i,j,k,l=0; + int a=0,b=1; + arr[0]=0;arr[1]=1; + for(i=2;i +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; + + int i,j,k,l; + for ( i=0; i +using namespace std; +int main(int agrc, char** argv){ + int n; + cin >> n; + int i,j,k; + for(i=1;i<=10;i++) + { + cout << n << " * " << i << " = " < +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; + int sp = n / 2, st = 1; + for (int i = 1; i <= n; i++) + { if(i <= n/2) + k=i; + else + k=n-i+1; + for (int j = 1; j <= sp; j++) + { + cout<<"\t"; + } + for (int j = 1; j <= st; j++) + { + cout< + +using namespace std; + +int main() +{ + + int i,j,k,l,m,n; + cin >> n; + for(i=1;i<=n;i++) + { + for(j=1;j<=i;j++) + { + cout<=i;k--) + { + cout<<"\t"; + } + for(k=n-2;k>=i;k--) + { + cout<<"\t"; + } + for(m=i;m>=1;m--) + { + if(i==n) + { + cout< +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; + int sp = n / 2, st = 1; + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= sp ; j++) + { + if ( i == n / 2 + 1) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + for (int j = 1 ; j <= st; j++) + { + cout<<"*\t"; + } + if ( i <= n / 2) + { + st++; + } + else { + st--; + } + cout<<"\n"; + } + } + diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern18.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern18.cpp new file mode 100644 index 00000000..507e555e --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern18.cpp @@ -0,0 +1,36 @@ +#include +using namespace std; +int main(int agrc, char**argv){ + int n; + cin >> n; +int i,j,k,l; + int sp=0,st=n; + for(i=1;i<=n;i++) + { + for(j=1;j<=sp;j++) + cout<<"\t"; + for (int j = 1; j <= st; j++) + { + if ( i > 1 && i <= n / 2 && j > 1 && j < st) + { + cout<<"\t"; + } + else + { + cout<<"*\t"; + } + } + cout<<"\n"; + + if(i<=n/2) + { + sp=sp+1; + st=st-2; + } + else + { + sp=sp-1; + st=st+2; + }} + cout<<"\n"; +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern19.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern19.cpp new file mode 100644 index 00000000..9d83df49 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern19.cpp @@ -0,0 +1,64 @@ +#include +using namespace std; +int main(int argc, char** argv){ + int n; + cin >> n; + +int i,j,k,l; +for(i = 1;i <= n; i++) +{ + for (int j = 1 ; j <= n; j++) + { + if ( i == 1) + { + if ( j == n || j <= (n +1) / 2) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + else if (i <= n / 2) + { + if ( j == n || j == (n + 1)/ 2 ) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + else if ( i == (n + 1) / 2 ) + { + cout<<"*\t"; + } + else if (i < n) + { + if (j == 1 || j == (n +1) /2) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + else + { + if (j == 1 || j >= (n +1) / 2) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + } + cout< +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i=0;j--) + { + if(j>=i) + { + cout<<"*\t"; + } + + + } + cout << endl; +} + +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern20.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern20.cpp new file mode 100644 index 00000000..5c7104e1 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern20.cpp @@ -0,0 +1,27 @@ +#include +using namespace std; +int main(int argc, char** argv){ + int n; + cin >> n; + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= n; j++) + { + if ( j == 1 || j == n) + { + cout<<"*\t"; + } + else if (i > n / 2 && (i == j || i + j == n + 1)) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + cout<< endl; + } + } + + \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern3.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern3.cpp new file mode 100644 index 00000000..f234e640 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern3.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i=0;j--) + { + if(j>i) + { + cout<<"\t"; + } + else + cout <<"*\t"; + + + } + cout << endl; +} + +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern4.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern4.cpp new file mode 100644 index 00000000..8f423c29 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern4.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i=i) + { + cout<<"*\t"; + } + else + cout <<"\t"; + + + } + cout << endl; +} + +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern5.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern5.cpp new file mode 100644 index 00000000..d5e2f315 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern5.cpp @@ -0,0 +1,31 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; + int sp = n / 2, st = 1; + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= sp; j++) + { + cout<<"\t"; + } + for (int j = 1; j <= st; j++) + { + cout<<"*\t"; + } + if ( i <= n / 2) + { sp--; + st += 2; + } + else + { + sp++; + st -= 2; + } + cout<< endl; + + } +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern6.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern6.cpp new file mode 100644 index 00000000..695dcca7 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern6.cpp @@ -0,0 +1,35 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; + int sp = (n+1)/ 2, st = 1; + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= sp; j++) + { + cout<<"*\t"; + } + for (int j = 1; j <= st; j++) + { + cout<<"\t"; + } + for (int j = 1; j <= sp; j++) + { + cout<<"*\t"; + } + if ( i <= n / 2) + { sp--; + st += 2; + } + else + { + sp++; + st -= 2; + } + cout<< endl; + + } +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern7.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern7.cpp new file mode 100644 index 00000000..3266a4ac --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern7.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i=0;j--) + { + if(j==i) + cout<<"*\t"; + else + cout << "\t"; + + + } + cout << "\n"; +} + +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern9.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern9.cpp new file mode 100644 index 00000000..7bcfc39d --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern9.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; + int i,j,k; + k = n-1; +for(i=0;i Date: Sun, 23 Oct 2022 11:29:04 +0530 Subject: [PATCH 5/5] programs of function and array --- .../FunctionandArrays/AnyBaseToDecimal.cpp | 21 +++++++++++++++ .../FunctionandArrays/DecimaltoAnyBase.cpp | 22 ++++++++++++++++ .../FunctionandArrays/DigitFrequency.cpp | 26 +++++++++++++++++++ .../FindElementInAnArray.cpp | 19 ++++++++++++++ .../FunctionandArrays/SpanOfArray.cpp | 25 ++++++++++++++++++ 5 files changed, 113 insertions(+) create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/AnyBaseToDecimal.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/DecimaltoAnyBase.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/DigitFrequency.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/FindElementInAnArray.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/SpanOfArray.cpp diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/AnyBaseToDecimal.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/AnyBaseToDecimal.cpp new file mode 100644 index 00000000..d7532303 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/AnyBaseToDecimal.cpp @@ -0,0 +1,21 @@ +#include +#include +using namespace std; +int AnyToDec(int n, int b) { +int d,r,s=0,i=0,t; +while(n!=0){ +t=pow(b,i); +r=n%10; +s=s+(r*t); +i++; +n=n/10;} +return s; +} +int main() { + int n; + int b; + cin >> n; + cin >> b; + int res = AnyToDec(n, b); + cout << res << endl; +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/DecimaltoAnyBase.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/DecimaltoAnyBase.cpp new file mode 100644 index 00000000..8511e5d4 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/DecimaltoAnyBase.cpp @@ -0,0 +1,22 @@ +#include +#include +using namespace std; +int DecToAny(int n, int b) { + int i=0,d,r,s=0; + while(n != 0) + { + d = n % b; + s = s + d * pow(10.0,i); + n = n / b; + i++; + } +return s; +} +int main() { + int n; + int b; + cin >> n; + cin >> b; + int res = DecToAny(n, b); + cout << res << endl; +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/DigitFrequency.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/DigitFrequency.cpp new file mode 100644 index 00000000..31e51014 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/DigitFrequency.cpp @@ -0,0 +1,26 @@ +#include +#include +using namespace std; +int digFreq(int n,int d) +{ + int r, c = 0; + while(n != 0) + { + r = n % 10; + if(r == d) + c++; + n=n/10; + } + return c; +} +int main() { + int n, d; + cin >> n >> d; + long int r; + r=pow(10.0,9.0); + if(n >= 0 && n <= r && d >= 0 && d <= 9) + { + int res = digFreq(n, d); + cout << res << endl; +} +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/FindElementInAnArray.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/FindElementInAnArray.cpp new file mode 100644 index 00000000..ed07a83d --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/FunctionandArrays/FindElementInAnArray.cpp @@ -0,0 +1,19 @@ +#include +#include +using namespace std; +int main() { + int x, n,i,j,el,k=-1; + cin >>n; + int *arr ; + arr = (int*)malloc(n*sizeof(int)); + for (x = 0; x < n; x++) { + cin >> arr[x]; + } + cin >> el; + for(i=0;i +#include +using namespace std; +int main() { + int x, n,i,k,max,min; + cin >>n; + int *arr ; + arr = (int*)malloc(n*sizeof(int)); + for (x = 0; x < n; x++) { + cin >> arr[x]; + } + min=arr[0]; + max=arr[0]; + for(i=1;iarr[i]) + min = arr[i]; + + if(max