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 |
Where does the name "C" come from, anyway?
what is c language?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
What are directives in c?
Can we change the value of #define in c?
How many main () function we can have in a project?
1. Write the function int countchtr(char string[ ], int ch); which returns the number of times the character ch appears in the string. Example, the call countchtr(“She lives in NEWYORK”, ‘e’) would return 3.
What are predefined functions in c?
Explain the difference between the local variable and global variable in c?
without a terminator how can we print a message in a printf () function.
How. To pass the entrance test
what is void pointer?