Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone post me the following codes in C Program 1: Write a program that inp

ID: 3761358 • Letter: C

Question

Can someone post me the following codes in C

Program 1:

Write a program that inputs a series of integers and passes them one at a time to function even, which uses the modulus operator to determine whether an integer is even. The function should take an integer argument and return true if the integer is even and false otherwise.

Sample Output

Enter an integer: 4

4 is an even integer

Enter an integer: 3

3 is an odd integer

Enter an integer: 2

2 is an even integer

Program 2:

Write a function that takes an integer value and returns the number with its digits reversed. For example, given the number 7631, the function should return 1367. A loop is required for the program.

Sample Output

Enter a number between 1 and 9999: 7631

The number with its digits reversed is: 1367

Explanation / Answer

#include<stdio.h>
#include<conio.h>

int even(int n)
{
   int i;

   if(n%2==0)
       return 1;
   else
       return 0;
}

void main()
{
   int n,i,c;

   for(i=0;i<4;i++)
   {
       printf(" Enter an Integer:");
       scanf("%d",&n);

       c=even(n);
       if(c==1)
           printf(" %d is an even integer",n);
   }
   getch();
}

Program 2:


#include<stdio.h>
#include<conio.h>
void main ()
{
   int i,a,x;
   clrscr();
   printf("enter the number between 1 and 9999:");
   scanf("%d",&a);
   i=1;

printf("The number with its digits reversed is:");
   while(i<=4)
   {
      x=a%10;
      printf("%d",x);
      a=a/10;
      i++;
    }
   getch();
}