From a6a578f585edad26c9f114c31c210c2327888c46 Mon Sep 17 00:00:00 2001 From: sruti2024 Date: Wed, 15 Jan 2020 11:34:13 +0530 Subject: [PATCH 1/4] adding c++ program to generate kaprekar number --- kaprekar_number.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 kaprekar_number.cpp diff --git a/kaprekar_number.cpp b/kaprekar_number.cpp new file mode 100644 index 0000000..eddffc8 --- /dev/null +++ b/kaprekar_number.cpp @@ -0,0 +1,37 @@ +#include +#include +using namespace std; +int sum(int n) + { + int m=n,d=0; + int s=m*m; + //while loop begins to count the number of digits + while(n!=0) + { + d++; + n=n/10; + } + int a=s%(int)pow(10,d); + int b=s/(int)pow(10,d); + int su=a+b; + return(su); + } + int main() + { + int k=0,num,m; + cout<<"Enter the upper and lower limits :"<>num>>m; + //displaying the reasult + cout<<"The kaprekar numbers within "< Date: Wed, 15 Jan 2020 12:54:56 +0530 Subject: [PATCH 2/4] adding c++ program to generate julian date --- julian_date.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 julian_date.cpp diff --git a/julian_date.cpp b/julian_date.cpp new file mode 100644 index 0000000..62c30c0 --- /dev/null +++ b/julian_date.cpp @@ -0,0 +1,48 @@ +#include +#include +using namespace std; + int dd=0,mm=0,yy=0; + int jd=0; + + int fnleap() + { + cout<<"Enter day:"<>dd; + cout<<"Enter month:"<>mm; + cout<<"Enter year:"<>yy; + if(yy%4==0) + return(1); + else + return(0); + } + int fnisvalid() + { + if(dd<1||dd>31) + return(0); + if(mm<1||mm>12) + return(0); + if(yy<1) + return(0); + else + return(1); + } + int main() + { + int endm[]={31,29,31,30,31,30,31,31,30,31,30,31}; + if(fnleap()==0) + endm[1]=28; + int r=0; + int p=fnisvalid(); + if(p==0) + { + cout<<"INVALID INPUT !!!!"< Date: Sat, 25 Jan 2020 15:39:21 +0530 Subject: [PATCH 3/4] addind c++ program to generate diamond pattern --- diamond_pattern.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 diamond_pattern.cpp diff --git a/diamond_pattern.cpp b/diamond_pattern.cpp new file mode 100644 index 0000000..9bc8cc5 --- /dev/null +++ b/diamond_pattern.cpp @@ -0,0 +1,34 @@ +#include +#include +using namespace std; +int main() +{ + int i,j,k,m=5; + //message to be displayed on screen + cout<<"Enter a character"<>ch; + cout<<"The required pattern:"<=1;i--) + { + for(j=1;j<=m;j++) + cout<<" "; + for(k=1;k<=i;k++) + cout< Date: Sat, 25 Jan 2020 16:01:19 +0530 Subject: [PATCH 4/4] adding program to generate circular matrix --- circular matrix.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 circular matrix.cpp diff --git a/circular matrix.cpp b/circular matrix.cpp new file mode 100644 index 0000000..e2cf850 --- /dev/null +++ b/circular matrix.cpp @@ -0,0 +1,46 @@ +#include +#define ll long long +using namespace std; +int main() +{ + int n,r1,r2,c1,c2,k=1,i,j; + cout<<"Enter matrix size:"<>n; + int a[n][n]; + c1=0;c2=n-1;r1=0;r2=n-1; + do + { + //arranging the matrix + for(i=c1;i<=c2;i++) + { + a[r1][i]=k; + k++; + } + for(j=r1+1;j<=r2;j++) + { + a[j][c2]=k; + k++; + } + for(i=c2-1;i>=c1;i--) + { + a[r2][i]=k; + k++; + } + for(j=r2-1;j>=r1+1;j--) + { + a[j][c1]=k; + k++; + } + c1++;c2--;r1++;r2--; + } + while(k<=n*n); + //printing the new matrix + cout<<"Circular matrix is listed below:"<