In: Computer Science
Write a function called is_equal(). This function will take as an argument two integers.
Compare the two integers. If the two integers are equal, then print "equal". If the two integers are not equal, print "not equal".
Sample output:
equal
Sample output:
not equal
Here our task is to create a function called 'is_equal' which check the equality between two integers and print apropriate result
points to remember
(You didnt mentioned any specific language to code this,hence i assume any language is fine .If you need code in a specific language please repost the question mentioning the language you need help with)
Now let's see how to code this in C++
CODE
(Please read all comments for tthe better understanding of the program)
SAMPLE RUN
I am also attaching the text version of the code in case you nee to copy paste
#include <iostream>
using namespace std;
void is_equal(int x,int y){ //'is_equal' function definition
if (x==y){ //check whether x is equal to y or not
cout<<"equal"; //if yes print equal
}
else{ //if not equal 'Not equal 'will print
cout<<"not equal";
}
}
int main() //main function starts here
{
is_equal(10,10); // calling the is_equal function with integer
value 10,10
return 0;
}