Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ absolute value

#include <stdio.h>      /* printf */
#include <stdlib.h>     /* abs */

int main ()
{
  int n,m;
  n=abs(23);
  m=abs(-11);
  printf ("n=%d
",n);
  printf ("m=%d
",m);
  return 0;
}
Comment

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<<"
The difference between the years is: "<<diff;	
}	
Comment

PREVIOUS NEXT
Code Example
Cpp :: prime number program in c 
Cpp :: qlabel font color 
Cpp :: recursive binary search 
Cpp :: default rule of five c++ 
Cpp :: create n threads cpp 
Cpp :: c++ print byte as bit 
Cpp :: c++ round number to whole 
Cpp :: unclebigbay 
Cpp :: c++ find largest number in array 
Cpp :: Sort array using inbuilt sort function in decreasing order 
Cpp :: convert decimal to binary c++ 
Cpp :: c++ program to calculate discount 
Cpp :: cmath sqrt 
Cpp :: to_string c++ 
Cpp :: c++ kruskal algorithm 
Cpp :: c++ evaluate expression 
Cpp :: c++ looping 
Cpp :: how to round a double to 2 decimal places in c++ 
Cpp :: syntax c++ 
Cpp :: http.begin arduino not working 
Cpp :: change to lowercase character c++ 
Cpp :: struct and array in c++ 
Cpp :: c++ reading string 
Cpp :: c++ random number within range 
Cpp :: c++ typing animation 
Cpp :: cpp std list example 
Cpp :: how to rotate canvas android 
Cpp :: how to get the size of a vector in c++ 
Cpp :: c++ vector declaration 
Cpp :: how to declare a 2d boolean vector in c++ 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =