#include
#include
void main()
{
Static int x,s,a,z,o;
chartxt[20];
clrscr();
printf(“Enter numbers”);
gets(txt);
while(txt[x]!=‟\0‟)
{
Switch(txt[x])
{
case‟‟:
s++;
break;
default:
switch(txt[x])
{
case‟1‟:
a++;
break;
case‟0‟:
z++;
break;
default:
o++‟
}
}
X++;
}
Printf(“
total spaces:%d”, s);
Printf(“
total 1s:%d”, a);
Printf(“
total 0s:%d”, z);
Printf(“
others:%d”, o);
Printf(“
string length:%d”, s+a+z+o);
}
getch();
}
Output:
Enter numbers:1110022 222
Total spaces :1
Total 1s :1
Total 0s :2
Others :5
String length :11