Assignment 0 Question 2

/*
Name :- Vinayak Sharma
SMVDU, jammu ECE
code description:- This code will take the input of 2 numbers and then calculate their average. Ultimately displaying the result!
*/
#include <stdio.h>
int main()
{
int a, b, avg;

scanf("%d", &a); /* this will take the input of first number */

scanf("%d", &b); /* this will take the input of 2nd number */

if ((a%2 == 0) & (b%2 == 0)) /* this if statement will check wether the numbers entered are even or odd, if odd then the calculation will be carried out. */
{

avg = (a + b)/2 ; /* mathematical operation which will conduct the average and then store it in the avg variable */

printf("%d", avg);  /* final statement which will display the average of 2 numbers */

}
else
{
printf("one or both of the numbers entered by the user was a odd number \n");
}

return 0;
}

Comments

Popular posts from this blog

Assignment 6 Question 3

Assignment 8 Question 1

Assignment 7 Question 2