C++

#Leap year problem in C++:

print it in your Code::blocks:

#include <iostream>
using namespace std;
int main()
{
    cout<<"Enter the year:";
    int x;
    cin>>x;
    if(x%4==0)
    {
        cout<<"yes this year is leap year :)";
    }
    else if(x%400==0)
    {
        cout<<"yes this year is leap year :)";
    }
    else if(x%100==0)
    {
        cout<<"no this year is not leap year :(";
    }
    else
    {
        cout<<"no this year is not leap year :( ";
    }
}


#another code
#positive or negative number found

print it in your Code::blocks:

#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>0)
    {
        cout<<n<<"is positive.";
    }
    else if(n<0)
    {
        cout<<n<<"is negative.";
    }
    else
    {
        cout<<n<<"is neither positive nor negative.";
    }
}




int
n
;
cin>>n;
if(n>0)
{
cout << n << " is positive.";
}
else if(n<0)
{
cout << n << " is negative.";
}
else
{
cout << n << " is neither positive nor negative.";
}
int
n
;
cin>>n;
if(n>0)
{
cout << n << " is positive.";
}
else if(n<0)
{
cout << n << " is negative.";
}
else
{
cout << n << " is neither positive nor negative.";
}

Comments