wap in c to accept a number display the total count of digit
Answers were Sorted based on User's Feedback
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 |
#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 |
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 |
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 |
What is the difference between %d and %i?
What is the significance of an algorithm to C programming?
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
What is the difference b/w Structure & Array?
What is I ++ in c programming?
fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }
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
what are far pointers?
How to write the code of the program to swap two numbers with in one statement?
Is c# a good language?
what is the use of keyword volatile??
What is data structure in c language?