Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions diamond_pattern.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
int i,j,k,m=5;
//message to be displayed on screen
cout<<"Enter a character"<<endl;
char ch;
cin>>ch;
cout<<"The required pattern:"<<endl;
//printing the pattern
for(i=1;i<=5;i++)
{
for(j=1;j<=m;j++)
cout<<" ";
for(k=1;k<=i;k++)
cout<<ch<<" ";
cout<<endl;
m=m-1;
}
m=2;
for(i=4;i>=1;i--)
{
for(j=1;j<=m;j++)
cout<<" ";
for(k=1;k<=i;k++)
cout<<ch<<" ";
cout<<endl;
m=m+1;
}
}


48 changes: 48 additions & 0 deletions julian_date.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int dd=0,mm=0,yy=0;
int jd=0;

int fnleap()
{
cout<<"Enter day:"<<endl;
cin>>dd;
cout<<"Enter month:"<<endl;
cin>>mm;
cout<<"Enter year:"<<endl;
cin>>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 !!!!"<<endl;
exit(0);
}
for(int i=0;i<mm-1;i++)
r=endm[i]+r;
jd=dd+r;
cout<<"JULIAN DATE :"<<jd;
}

37 changes: 37 additions & 0 deletions kaprekar_number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include<bits/stdc++.h>
#include<math.h>
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 :"<<endl;
cin>>num>>m;
//displaying the reasult
cout<<"The kaprekar numbers within "<<m<<" and "<<num<<" : "<<endl;
for(int i=m;i<=num;i++)
{
if(sum(i)==i)
{
cout<<i<<"\t";
k++;
}
}
cout<<endl;
}