Seven Segment Display
They are working on building seven segment displays. But the Company wanted to know how many seven segment displays will they need to represent an Integer x. They use one seven segment display to represent one digit of an Integer. For example: Integer "100" needs "3" seven segment boards to be represented.
Help them find out how many displays are needed?
Input Format:
First and only line consists of one positive integer that needs to be represented using seven segment displays.
Output Format:
Output a single line containing the number of digits of that integer.
Refer sample input and output for formatting specifications.
Sample Input 1:
1
Sample Output 1:
1
Sample Input 2:
1000
Sample Output 2:
4
C program
#include<stdio.h> int main() { int inp,count=0,value=1; scanf("%d",&inp); while(1) { if(inp==1 || inp==0) { printf("1"); break; } if(value<=inp) { value*=10; count++; } else{ printf("%d",count); break; } } }
Comments
Post a Comment