Write a C program that reads one integer at a time from stdi
Write a C program that reads one integer at a time from stdin and uses a function to determine if each integer contains an even or odd number of 1 bits. Stop on EOF. Output to stdout and end output for each integer with a newline. Output: \"even\" or \"odd\" for each input integer. Write a C program that reads one hexadecimal integer at a time from stdin and uses a function to print out the binary representation. Separate 4-bit increments with a space. Stop on EOF. Output to
Solution
Input comes from the standard input device, stdin.
Output is generated by the standard output device, stdout
So these Function prototypes are defined in \"stdio.h\" headre file.
Just include it in ur code
#include stdio.h
int main()
{
int number;
printf(\"enter an integer\");
scanf(\"%d\",&number);
If (number %2 == 0)
Printf(\"%d is even \", number);
else
printf(\"%dis not even\", number);
return 0;
}
secondway:
#include stdio.h
int main()
{
int number;
printf(\"enter an integer\");
fgets( integer, 2,stdin);
If (number %2 == 0)
fputs(“Even number”, stdout);
else
fputs(“odd number”, stdout);
