Showing posts with label Syntax. Show all posts
Showing posts with label Syntax. Show all posts

Tuesday, 26 September 2017

write a program to check leap year or not in c++

C++ Program to Check Leap Year

This program check given number is year leap or not.

You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and for loop

Leap year that is given number divided by
4.if number is perfectly divided to 4 its also
known as leap year.
leap year such as 2004,2008,2012,2016,2020

Example: Check given a year is leap year or not

#include <iostream>
#include <conio.h>
using namespace std;

int main()
    int y;

    cout << "Plz Enter a year: ";
    cin >> y;

    if (y % 4 == 0)
        if (y % 100 == 0)
            if (y % 400 == 0)
                cout << y << " leap year.";
                cout << y << "not leap year.";
            cout << y << " leap year.";
        cout << y << " not leap year.";

    return 0;

Plz Enter a year: 2012
2012 leap year.

The  people who want to learn programming language.this website very beneficial for those people.

Thursday, 14 September 2017

Structure and Syntax of program in c++

 Structure and Syntax of program

c++ Program | Syntax 

This Program we show prints Hello World on screen 

#include <iostream.h>
using namespace std;
int main ()
cout << "Hello World! Syntax ";
return 0;

1 . /* This program ... */
The symbols/* and*/ used for comment. This Comments are ignored by the compiler, and are used to provide useful information about program to humans who use it.

2. #include <iostream.h>

This is a preprocessor command which tells compiler to include iostream.h file.

3. using namespace std; 

All the elements of the standard C++ library are declared within what is called a namespace, the namespace with the name std. So in order to access its functionality we declare Syntax with this expression that we will be using these entities. This line is very frequent in C++ programs Syntax that use the standard library.

4. main()

C++ programs consist of one or more functions. There must be one and only one function called main. The brackets following the word main indicate that it is a function and not a variable .

5. { }
Syntax braces surround the body of the function, which may havee one or more instructions/statements.

6. Cout<<

it is a library function that is used to print data on the user screen.

7. ''Hello World'' is a string that will be displayed on user screen 

8. ; a semicolon ends a statement Syntax .

9. return 0; return the value zero to the Operating system.