A C program which calls a function to ask users to enter three integers. Add thr
ID: 3667592 • Letter: A
Question
A C program which calls a function to ask users to enter three integers. Add three functions which enable the program to do the following things
(a)add a function geteven() to display the even numbers from three integers.
(b)add a function getcount() to find the number of digits in a number.
(c)add a function getreverse() to reverse a string.
the original code is shown in the picture.
cl test.c × include int getint (void); /*It prompts user to enter an integer, which it returns*/ /* Main program*/ int main (void) { int x; x = getInt ( ) ; printf("The number entered is %d ", x); int getint (void) int a; printf ("Please enter an integer > "); scanf("sd", &a;); return (a);Explanation / Answer
#include<stdio.h>
#include<conio.h>
int getint()
{
int a;
printf("Please Enter an Integer >");
scanf("%d",&a);
return (a);
}
void geteven(int x)
{
int a= x%2;
if(a==0)
{
printf("Number %d is even",x);
}
}
void getcount(int x)
{
int c=0;
while(x>0)
{
x=x/10;
c++;
}
printf("Count of digits in a number is %d",c);
}
void getreverse()
{
char name[10];
printf("Enter your name");
scanf("%s",name);
for(int i=9;i>=0;i--)
printf("%c",name[i]);
}
void main()
{
int x;
x=getint();
printf("The number Entered is %d ",x);
geteven(x);
getcount(x);
getreverse();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.