| Current Path : /var/www/html/bibhas.ghoshal/ITP_2019/lab/ |
| Current File : /var/www/html/bibhas.ghoshal/ITP_2019/lab/prog9.c |
#include <stdio.h>
int main(void)
{
int inta, intb;
printf("Enter two non-zero integers: ");
scanf("%d %d", &inta, &intb);
if (inta == 0| intb == 0) {
printf("At least one integer is zero");
return 1; /* Good to return nonzero for invalid entry */
}
/* Assigning absolute values to inta and intb */
if (inta < 0) {
inta = -inta; /* Using the unary operator */
}
if (intb < 0) {
inta = -intb;
}
/*If we have come here, both inta and intb must be positive */
printf("Average of absolute value of the integers %.2f\n",(float) (inta + intb) / 2);
return 0;
}