Answers for "absolute value in c"

C
0

abs function in c language

//abs is function which returns absolute value of a integer 
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int m = abs(34);     // m is assigned to 200
   int n = abs(-40);    // n is assigned to -400
 
   printf("Absolute value of m = %dn", m);
   printf("Absolute value of n = %d n",n);
   return 0;
}
Posted by: Guest on June-19-2021
0

c absolute value

#include <stdio.h>
#include <stdlib.h>

int main() 
{
	int a;
	printf("ABSOLUTE VALUEnnNumer: ");
	scanf("%d",&a);
    
	if(a < 0)
	{
		a = a * (-1);
	}
    
	printf("Absolute value: %dnn", a);
    
	system("pause");
}
Posted by: Guest on February-11-2021

Code answers related to "C"

Browse Popular Code Answers by Language