tag:blogger.com,1999:blog-959939550345671470.post6231653691975276689..comments2024-03-24T12:51:18.535+05:30Comments on C programming Interview questions and answers: C program to count number of digits in a numberPriyanka kumarihttp://www.blogger.com/profile/08145649011863585828noreply@blogger.comBlogger39125tag:blogger.com,1999:blog-959939550345671470.post-19630636658784913122017-07-26T14:10:06.842+05:302017-07-26T14:10:06.842+05:30This program is correct guys...it also works with ...This program is correct guys...it also works with 0s...eg:my num is 20000 it prints 5 digits in the number.Shankavihttps://www.blogger.com/profile/14697794625675323310noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-59212443682219101502017-07-12T21:39:50.832+05:302017-07-12T21:39:50.832+05:30Code 1 why u used num=num/10? Code 1 why u used num=num/10? Anonymoushttps://www.blogger.com/profile/15660969725266543296noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-87962515813114819432017-07-12T21:38:45.771+05:302017-07-12T21:38:45.771+05:30This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/15660969725266543296noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-75576612784960724462017-07-12T21:38:44.812+05:302017-07-12T21:38:44.812+05:30This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/15660969725266543296noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-63973227487870673122017-07-06T14:04:36.153+05:302017-07-06T14:04:36.153+05:30If i enter "0000" as input it shows '...If i enter "0000" as input it shows '0' as output.......<br />But actually the length of the integer is '4'. Can you please post the solution for it. Thanks in advance.Anonymoushttps://www.blogger.com/profile/07689133856328683065noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-80090779615827657532017-05-17T17:00:42.018+05:302017-05-17T17:00:42.018+05:30This comment has been removed by the author.Parthiban Bhttps://www.blogger.com/profile/11389492555514674036noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-72299807141565664122016-11-17T15:36:41.433+05:302016-11-17T15:36:41.433+05:30In this program have one mistake..that is (int num...In this program have one mistake..that is (int num) 0 cannot be read the compiler,so using (long int num) the program will correctly executed in more than digits.. Mr. Contenthttps://www.blogger.com/profile/03315300418516733799noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-49804988935121545042016-07-29T07:08:47.206+05:302016-07-29T07:08:47.206+05:30<it's really super><it's really super><br />Anonymoushttps://www.blogger.com/profile/15103845129462426430noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-42675763741019151562016-06-20T20:56:06.031+05:302016-06-20T20:56:06.031+05:30Nicely Done.!Nicely Done.!Nishant Ranjanhttps://www.blogger.com/profile/18400192846307841939noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-37375860912295886952016-04-03T15:07:35.159+05:302016-04-03T15:07:35.159+05:30but it won t work if number have more than 10 digi...but it won t work if number have more than 10 digits<br />roberthttps://www.blogger.com/profile/12102410318708237224noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-65487373485674470572015-12-03T03:50:34.968+05:302015-12-03T03:50:34.968+05:301. int calculateOccurrenceOfDigit(int number, int ...1. int calculateOccurrenceOfDigit(int number, int digit); <br /><br />Complete the above prototyped function that will return total number of occurrence of digit in a number. For e.g. calculateOccurrenceOfDigit( 102015400, 0) will return 4 as it has 4 zeros.<br />You have to use recursion.<br /><br />int calculateOccurrenceOfDigit(int number, int digit)<br />{<br />.............. i need the Anonymoushttps://www.blogger.com/profile/09821257314842698285noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-11075651494778705732015-07-02T10:54:20.619+05:302015-07-02T10:54:20.619+05:30*
* *
* * *
* *
*
i want this program.plz help me...*<br />* *<br />* * *<br />* *<br />* <br />i want this program.plz help me<br />Anonymoushttps://www.blogger.com/profile/17569579958293740895noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-79300692802057456232015-03-19T10:12:42.588+05:302015-03-19T10:12:42.588+05:30need count the digits of a given number using do w...need count the digits of a given number using do while & while loop<br />suhashttps://www.blogger.com/profile/16129713324117886228noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-44118026721673408072015-03-14T04:50:10.196+05:302015-03-14T04:50:10.196+05:30Your program to calculate the no of digits in an i...Your program to calculate the no of digits in an integer is incorrect.<br />As an example try 20000.Fuserhttps://www.blogger.com/profile/01848390731207801967noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-15839276773754287882014-11-30T17:31:13.743+05:302014-11-30T17:31:13.743+05:30Write down the definition of a function count2s wh...Write down the definition of a function count2s which takes a number as argument and returns the count of the digit 2 in it?Anonymoushttps://www.blogger.com/profile/07865274856276572031noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-13371777984891384502014-06-01T12:40:30.256+05:302014-06-01T12:40:30.256+05:30thanksthanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-8081272034143872992014-02-25T03:40:14.604+05:302014-02-25T03:40:14.604+05:30This line int t=r; is not neededThis line int t=r; is not neededAleksandarhttps://www.blogger.com/profile/15861656176193246763noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-77473765333407651212014-02-25T03:38:52.737+05:302014-02-25T03:38:52.737+05:30This comment has been removed by the author.Aleksandarhttps://www.blogger.com/profile/15861656176193246763noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-28795581183906303992014-02-25T03:34:19.037+05:302014-02-25T03:34:19.037+05:30The following solution is even faster, although it...The following solution is even faster, although it needs log2(log10(n)) additional space because it uses recursion. It needs only log2(log10(n)) calls. It is basically a wrapped binary decomposition of exponent of 10.<br /><br />void nextLevel(int* n, int r, int* dig, int d)<br />{<br /> <br /> int t=r;<br /> r=r*r;<br /><br /> if(*n>=r)<br /> {<br /> d = 2 * Aleksandarhttps://www.blogger.com/profile/15861656176193246763noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-5136734897257203772014-02-24T12:33:45.260+05:302014-02-24T12:33:45.260+05:30There is much faster way which has complexity abou...There is much faster way which has complexity about (log(log10(n)))^2<br />For large numbers like 10^1000, you would need 1000 operations for all previous codes, with the code below around 50.<br />It is basically a binary search over the exponent of 10 in binary form. For example for 10^27 we search 1-2-4-8-16-32, then 1-2-4-8-16, then 1-2-4, then 1-2, and that is 16 guesses.<br />For small Aleksandarhttps://www.blogger.com/profile/15861656176193246763noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-88915520564903147022014-02-19T14:55:33.035+05:302014-02-19T14:55:33.035+05:30thankx a lot i think it will help me a lot. thanx ...thankx a lot i think it will help me a lot. thanx againAnonymoushttps://www.blogger.com/profile/08236127146597918457noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-83004624112289453602013-12-16T19:57:22.196+05:302013-12-16T19:57:22.196+05:30here main() is called....in main function.....recu...here main() is called....in main function.....recursively...untill i>100 :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-59970430588608914902013-11-25T16:59:45.550+05:302013-11-25T16:59:45.550+05:30hi Anand Barnwal you used main(); inside if condit...hi Anand Barnwal you used main(); inside if condition i dint get can u explain it.. thanksAnonymoushttps://www.blogger.com/profile/07414400498604156578noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-46044506443490049562013-11-10T22:27:02.059+05:302013-11-10T22:27:02.059+05:30but this program will not count 0 which is also a ...but this program will not count 0 which is also a digit.<br />for example 123=3<br />43078=5<br />0=1<br />we count digits <br />0 is also a number<br />So Correct ur program.Anonymoushttps://www.blogger.com/profile/01893504636161077733noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-41464794066243855892013-11-06T12:16:10.912+05:302013-11-06T12:16:10.912+05:30but this progarm run to count only 10 digit after ...but this progarm run to count only 10 digit after that what should we do Anonymoushttps://www.blogger.com/profile/15662901547933357915noreply@blogger.com