diff --git a/Q1.cpp b/Q1.cpp new file mode 100644 index 0000000..35878d9 --- /dev/null +++ b/Q1.cpp @@ -0,0 +1,12 @@ +#include +using namespace std; + +int main() +{ int num; + cout<<"Enter the Number: ; + cin>>num; + if(num == 0) + cout << "Zero"; else (num > 0) ? cout << "Positive": cout << "Negative"; + + return 0; +} diff --git a/Q2.cpp b/Q2.cpp new file mode 100644 index 0000000..2b957b2 --- /dev/null +++ b/Q2.cpp @@ -0,0 +1,8 @@ +#include +using namespace std; +int main() { + int num; + cout<<"Enter the number: "; + cin>>num; + num%2==0?cout<<"Even Number!!":cout<<"Odd Number!!"; +} diff --git a/Q3.cpp b/Q3.cpp new file mode 100644 index 0000000..2e11222 --- /dev/null +++ b/Q3.cpp @@ -0,0 +1,12 @@ +#include +using namespace std; +int main() { + int num; + cout<<"Enter the number: "; + cin>>num; + int sum=0; + for(int i=0;i +using namespace std; +int main() { + int l,u; + cin>>l>>u; + int sum=0; + for(int i=l;i<=u;i++){ + sum+=i; + } + cout<<"Sum of numbers in range: "< +using namespace std; +int main() { + int first_num,sec_num; + cin>>first_num>>sec_num; + int res = first_num>sec_num?first_num:sec_num; + cout<<"Greatest of two numbers is: "< +using namespace std; +int main() { + int x,y,z; + cin>>x>>y>>z; + cout<<"The greatest of the three numbers is: "; + if(x>y){ + if(x>z) + cout<z) + cout< +using namespace std; +int main() { + int year; + cin>>year; + if(year%400==0 || year%4==0 && year%100!=0) + cout<<"Leap year!"; + else + cout<<"Not a leap year!"; +}