“Nilai absolut CPP” Kode Jawaban

C Nilai Absolut

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

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

Nilai absolut CPP

#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;	
}	
Scorpion king

Jawaban yang mirip dengan “Nilai absolut CPP”

Pertanyaan yang mirip dengan “Nilai absolut CPP”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya