Apart from having lots of vacations throughout the year, residents of India also have whole fortune years. The year is considered a fortune if it has no more than 1 non-zero digit in its number.
So years 100, 40000, 5 are lucky and 12, 3001, and 12345 are not.
You are given the current year in India. Your task is to find how long will residents of India wait till the next fortune year.
Input:
The first line contains integer number n — the current year.
Output:
Print the output, amount of years from the current year to the next fortune one.
#include <stdio.h> int find_no_digits(unsigned long int data,int *first_digit) { int temp=0,c=0; while(data!=0){ temp=data%10; if(temp!=0){c+=1;} data=data/10; } if(c==1){*first_digit=1;} } int main() { int n,i,flag=0; scanf("%d",&n); i=n; while(flag==0){ i+=1; find_no_digits(i,&flag); } printf("%d",i-n); return 0; }
INPUT_1:
310
OUTPUT:
90
INPUT_2:
400
OUTPUT:
100
INPUT_3:
2025
OUTPUT:
975
INPUT_4:
1999
OUTPUT:
1
INPUT_5:
2999
OUTPUT:
1
ILLUSTRATION:
Morae Q!
- Find how long will it take till the next fortune year from the current year.
- Find if it’s possible to distribute all the crayons into boxes and satisfy all the conditions.
- Compute sum of numbers using call by reference.
- Compute the amount of money to be handed over with conditions.
- Find the total number of beautiful triplets in the sequence.
- Find the total amount each worker has to pay individually.
- Find the minimum distance between any pair of equal elements in the array.
- Compute the maximum possible value of the given equation.
- Find the age of the student at the time of joining.
- Compute the total number of photos at each restaurant .
- Find the sum of digits of the number using Union datatype.
- Generate the details of the novels in the expected format.
- Sort the student details based on their names in ascending order.
- Find a way to move the king from current position to different square on chessboard.
- Find the time differences in the two different time zones.
- Identifying the greatest number with a numerator and denominator.
- Find the Minimum number of packages to supply all the bases.
- Tower of Hanoi, A puzzle.
- Compute the sum of array of elements using recursion method.
- Find the super digit of an integer using the rules.