wap in c to accept a number display the total count of digit

Answers were Sorted based on User's Feedback



wap in c to accept a number display the total count of digit..

Answer / vaibhav

#include<stdio.h>
#include<conio.h>
void main()
{
int no,t,cnt=0;
clrscr();
printf("\n enter the no.");
scanf("%d",&no);
while(no!=0)
{
t=no%10;
no=no/10;
cnt++;
}
printf("\nTotal count of digit is%d",cnt);
getch();
}

Is This Answer Correct ?    19 Yes 4 No

wap in c to accept a number display the total count of digit..

Answer / santhi perumal

#include<stdio.h>
#include<conio.h>

int main()
{
int number,m,sum =0,count =0;

printf("Enter the number \n");
scanf("%d",&number);

while(number != 0)
{
m = number % 10;
sum = sum + m;
count++;
number = number / 10;
}

printf("\nThe number of Digits in the Given Number is
%d\n",count);
printf("The Sum of Digits in the Given Number is %d\n",sum);



}

Is This Answer Correct ?    19 Yes 5 No

wap in c to accept a number display the total count of digit..

Answer / govind279

#include<stdio.h>
int main()
{
int n,m,sum=0;
scanf("%d",&n);
for(m=0;((m=n%10)!=0);n=(n/10))
sum+=m;
printf("count is %d\n",sum);
}

Is This Answer Correct ?    14 Yes 10 No

wap in c to accept a number display the total count of digit..

Answer / sashidharan

main()
{
int n,count=0;
scanf("%d",&n);
for(i=0;i<=n;i++)
{
count=count+1;
}
printf("total count of digit",count);
}

Is This Answer Correct ?    22 Yes 20 No

Post New Answer

More C Interview Questions

What is the difference between %d and %i?

0 Answers  


What is the significance of an algorithm to C programming?

0 Answers  


Write an algorithm for a program that receives an integer as input and outputs the product of of its digits. E.g. 1234 = 24, 705 = 0

4 Answers  


What is the difference b/w Structure & Array?

6 Answers  


What is I ++ in c programming?

0 Answers  






fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }

17 Answers   NDS,


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

0 Answers  


what are far pointers?

1 Answers  


How to write the code of the program to swap two numbers with in one statement?

2 Answers  


Is c# a good language?

0 Answers  


what is the use of keyword volatile??

4 Answers   LG Soft,


What is data structure in c language?

0 Answers  


Categories