Developer community
0 votes
2.3k views
asked by Geek (15.3k points) 17 42 62 | 2.3k views

1 Answer

0 votes

#include<stdio.h>

#include<conio.h>

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(“\n total spaces:%d”, s);

Printf(“\n total 1s:%d”, a);

Printf(“\n total 0s:%d”, z);

Printf(“\n others:%d”, o);

Printf(“\n 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 

answered by Guru (39.1k points) 10 22 35

Related questions

0 votes
1 answer
0 votes
1 answer
asked by sara Guru (24.6k points) 29 52 82 | 2.4k views
+1 vote
1 answer
0 votes
1 answer
asked by smith Geek (15.3k points) 17 42 62 | 44 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

3,751 questions
4,046 answers
117 comments
10,709 users