The number of expressions is far more interesting than the number of statments. In the example code you have at least 3 expressions in the one for statment (which you also call 'single line').
you could do something like
do { sum += num % 10} while (num /= 10);
instead, which is better for most compilers, is also a single line, has one less expression in it (doesn't have num > 0) and doesn't reject negative numbers.
This comment has been removed by the author.
ReplyDeleteThe number of expressions is far more interesting than the number of statments. In the example code you have at least 3 expressions in the one for statment (which you also call 'single line').
ReplyDeleteyou could do something like
do { sum += num % 10} while (num /= 10);
instead, which is better for most compilers, is also a single line, has one less expression in it (doesn't have num > 0) and doesn't reject negative numbers.
u r awesome :)doing a great job
ReplyDeletenice post Interview Questions
ReplyDeletevoid sumdigit(int n) //single line
ReplyDelete{
int s = 0;
while((s=s+(n%10))&&(n=n/10)>0)
;
printf("\nSum of Difit : %d",s);
}
canada goose
ReplyDeletesupreme
nike vapormax
coach outlet store online
adidas yeezy
golden goose
nike shoes
air max 97
fila
michael jordan shoes