Adding one to every digit of number
Hi there,
I' m encountering the following warning:
Warning W8004 sum1num.c 7: 'd' is assigned a value that is never used in function main.
How can I remove it in this case and what should I do in case of any other code having this warning?? Also, is there any way to shorten this code and is my indentation right?
Here's the
Code:
#include <stdio.h>
#include <math.h>
/*Adding one to every digit of number*/
float main ()
{
int a, c = 0, e = 0, n, p, x;
float d = 0, b;
printf("Enter a number\n");
scanf("%d", &n);
p = n;
while (n != 0)
{
n = n/10;
c++ ;
}
for (b = 0; b<c; b++)
{
d = exp(b*log(10));
e = e + d;
}
x = p + e;
printf("The new number is = %d\n", x);
return 0;
}