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 :: how to convert ascii to char in cpp 
Cpp :: c++ insert into map 
Cpp :: how to square a number in c++ 
Cpp :: number of digits in int c++ 
Cpp :: panic: assignment to entry in nil map 
Cpp :: how to add external library in clion 
Cpp :: c++ struct 
Cpp :: c++ back() 
Cpp :: Find minimum maximum element CPP 
Cpp :: power function c++ 
Cpp :: C++ float and double Different Precisions For Different Variables 
Cpp :: factorial calculator c++ 
Cpp :: print two dimensional array c++ 
Cpp :: c++ hash combine 
Cpp :: word equation numbers 
Cpp :: reversing a string in c++ 
Cpp :: check if a key is in map c++ 
Cpp :: c++ loop through list 
Cpp :: vector iterating in c++ 
Cpp :: c++ remove chars from string 
Cpp :: convert all strings in vector to lowercase or uppercase c++ 
Cpp :: Finding square root without using sqrt function? 
Cpp :: online ide c++ 
Cpp :: How to use jwt in login api in node js 
Cpp :: sum of first 100 natural numbers 
Cpp :: program to swap max and min in matrix 
Cpp :: flutter single instance app 
Cpp :: volumeof a sphere 
Cpp :: declare empty array in c++ 
Cpp :: Arduino Real TIme Clock 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =