Horje
cpp absolute value Code Example
cpp absolute value
#include<iostream>
#include<cstdlib>
using namespace std;

int main()
{
	int fyear;			//for first year
	int ayear;			//for second year
	int diff;			//to find the difference 
	
	cout<<"Please Enter the first year: ";
	cin>>fyear;
	cout<<"Please Enter the Second year: ";
	cin>>ayear;
	
	diff=ayear-fyear;		//basically its the formula to get the difference between the years
	
	cout<<"The difference between the years is: "<<diff;
	
	diff=abs(diff);  		//to get absolute difference it converts any negative number into positive
	cout<<"\nThe difference between the years is: "<<diff;	
}	




Cpp

Related
round function in c++ Code Example round function in c++ Code Example
compare two functions in a class c++ Code Example compare two functions in a class c++ Code Example
c++ define array with values Code Example c++ define array with values Code Example
c++ set value to inf Code Example c++ set value to inf Code Example
c++ get microseconds since epoch Code Example c++ get microseconds since epoch Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10