59. WAP to add 1st and last digit , multiply digits which are between them.
#include<stdio.h>
void
main()
{
int num,r,c=0,mul=1,add=0;
printf("Enter a value : ");
scanf("%d",&num);
for(;num;num = num/10)
{
r=num%10;
if( c==0 || num<=9)
add=add+r;
else
mul=mul*r;
c++;
}
printf("Add = %d\n",add);
printf("Mul = %d\n",mul);
}
Comments
Post a Comment