0

[SOME HELP PLEASE] required any no. with odd no. of digit such as 199 or 19999 returned the same

/* write a c program in which a user will input a no.the program has to add 1 in each digit of a no. if the digit is 9 it has to be 0 it doesn't have to carry forward */ int main() { int num,dgt=0,rev=0,check,x=0; printf("\nEnter the number whose digits are to be added with one = "); scanf("%d",&num); while(num!=0) { dgt *= 10; check = num%10; if(check==9) { check=0; dgt = dgt+check; x++; } else { dgt = dgt+check+1; } num /=10; } while(dgt!=0) { rev *=10; rev = (rev+dgt%10)*pow(10,x); dgt /=10; } printf("\nThe number is = %d\n",rev); return 0; }

29th Jun 2016, 9:24 AM
Infinity
Infinity - avatar
2 Respuestas
29th Jun 2016, 7:08 PM
Garme Kain
Garme Kain - avatar
0
thanks man really helpful
30th Jun 2016, 3:15 AM
Infinity
Infinity - avatar