Skip to content
#include<iostream.h>
#include<conio.h>
class number
{
public:
int no;
int iseven()
{
if(no%2==0)
return 1;
else
return 0;
}
};
int main()
{
clrscr();
number x;
cout<<"Enter the number :";
cin>>x.no;
if(x.iseven())
cout<<"The number is even";
else
cout<<"The number is odd";
getch();
return 0;
}
Class diagram
(click image to view large)
Related Posts: C++ Program to implement Depth-first search in binary tree
In depth-first order, we always attempt to visit the node farthest from the root node that we can, but with the caveat that it must be a child of a n… Read More C++ program : To work with new and delete operation in constructor with class diagram
#include<iostream.h>
#include<conio.h>
#include<string.h>
class string
{
char*name;
int length;
&n… Read More C++ Program to implement Traversal in Binary tree.
In computer science, tree traversal (also known as tree search) refers to the process of visiting (examining and/or updating) eac… Read More C++ Program to Matrix: Addition, Subtraction, Multiplication and Transpose
#include<iostream.h>
#include<conio.h>
#define s 20
class matrix
{
int a[s][s],x,y;
//static int n;
&… Read More C++ Program to Show the working of Doubly linked list
In a doubly linked list, each node contains, besides the next-node link, a second link field pointing to the previous node in th… Read More
0 comments:
Post a Comment