I wrote a program where i have to input 4 integers, which will have their last digit added up and then the program will print out that the sum of the last digits is either even or odd. (e.g. The program basically has to say " The sum of the last digits of x,x,x, and x is even"). this is what i have so far but it won't print out what i want it to say. Any suggestions?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int even_odd(int num1, int num2, int num3, int num4);
int
main(void)
{
int w,x,y,z;
printf("Please enter first integer:\n");
scanf("%d",&w);
printf("Please enter a second integer:\n");
scanf("%d", &x);
printf("Please enter a third integer:\n");
scanf("%d", &y);
printf("Please enter a fourth integer:\n");
scanf("%d", &z);
int even_odd(int w,int x,int y,int z);
}
int even_odd(int num1, int num2, int num3, int num4)
{
int w = (num1%10);
int x = (num2%10);
int y = (num3%10);
int z = (num4%10);
int n = w+x+y+z;
if(n%2 == 0)
printf("The sum of the last digits of %d,%d,%d,and %d.\n is even", w,x,y,z);
else
printf("The sum of the last digits of %d,%d,%d,and %d.\n is odd", w,x,y,z);
system("pause");
return(0);
}