Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e1.cpp #35

Open
wants to merge 7 commits into
base: cpp
Choose a base branch
from
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
14 changes: 14 additions & 0 deletions e1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<iostream>
using namespace std;
main()
{
int a;
cout<<"enter a number"<<endl;
cin>>a;
if(a%2==0)
{
cout<<"Even"
}
else
cout<<"Odd";
}
16 changes: 16 additions & 0 deletions e2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@




#include<iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter the number:"<<endl;
cin>>num;
if(num>0) cout<<"Number is Positive"<<endl;
else if(num==0) cout<<"Number is '0'"<<endl;
else cout<<"Number is Negative";

}
26 changes: 26 additions & 0 deletions h1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include<iostream>
using namespace std;
int main()
{
int n=8,num=5,pattern[9][9];
//for first diogonal triangle
for(int i=0;i<=n/2;i++,num--)
for(int j=i;j<=n-i;j++)
{
pattern[i][j]=pattern[j][i]=num;
}
num=5;
//for second diogonal triangle
for( int i=n;i>=n/2;i--,num--)
for(int j=i;j>=n-i;j--)
{
pattern[i][j]=pattern[j][i]=num;
}
for(int i=0;i<=n;i++)
{
for(int j=0;j<=n;j++)
cout<<pattern[i][j]<<" ";
cout<<endl;
}

}
14 changes: 14 additions & 0 deletions p3_i.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter no. of rows:";
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=0;j<=i;j++)
cout<<"*";
cout<<endl;
}
}