my solution was so complicated IMO can i find something simpler...a) Write a function called eq3( ) that takes 3 arguments of type
integer and return integer. This function checks if the three integers
are equal. It returns 1 if they are equal and zero otherwise
b)Use the function eq3( ) to write a program that prompts the user to
enter three positive numbers continuously until the user enters any
character and each time the program checks if they are equal to
display a suitable message on the screen
this is what i did... am not daring to test it it's 3:15am over here
Code: Select all
#include <stdio.h>
#include <conio.h>
int eq3(int a, int b, int c){
if(a==b)
if(b==c)
return 1;
return 0;
}
int main() {
int notchar=1;
char buffer[200];
int number;
char *not_integer;
int ints[3];
int i;
do{
for(i=0;i<3;i++){
if(!notchar)
break;
while(true){
printf("Enter an integer: ");
scanf("%s", buffer);
number = strtol(buffer, ¬_integer, 10 );
if (*not_integer != '\0')
if(buffer[0]!=null && buffer[1]==null)
{notchar=0;break;}
else
{
fprintf("%s is not valid.\n", not_integer);
continue;
}
if(number<0)
{printf("you entered a negative integers, you need it to be positiv\n");continue;}
else{ints[i]=number;break;}
}
}
if(eq3(ints[0],ints[1],ints[2]))
printf("your integers are All equal");
else
printf("your integers are Unequal");
}
i=0;
while(notchar)
}