Write a program to accept a four digit number and print the sum of first and last digit and product of mid digits in C.



#include<conio.h>                        
#include<stdio.h>
void main()
{
  int n,a,b,c,d,e,f,g,sum,product; /* a,b,c,d,e,f,g are variable*/
  printf("Enter the four digit Number = ");
  scanf("%d",&n);
  a=n%10;//use for find out to modulas
  b=n/10;//usd for find out to division

  c=b%10;
  d=b/10;

  e=d%10;
  f=d/10;

  g=f%10;
  sum=a+g;
  product=c*e;
  printf("Sum of fist and last number = %d\n",sum);
  printf("Product of mid number = %d",product);
getch();
}


 OUTPUT :-




 
Previous Post
Next Post