LED PANEL

Google It, You'll Get It.

Monday, January 31, 2011

Scan and count the times you have used a number within a 5 digit Number + creates the inverse of the input

Input: 59585
Input: Scan for Number 5
Output: 5 have printed 3 times
Output: inverse 58595

----------------------------------------------------------

#include<'stdio.h'>

main()
{
long numb, rem, i, temp = 0, sum, in, count = 0;
printf("Input a 5 digit number \n");
scanf("%ld",&numb);
i = 1;

printf("Input a digit \n");
scanf("%ld",&in);

printf("\n");
while(i<=5)
{
temp=temp*10;
rem=numb%10;
if(rem==in)
count++; //c= rem, numb =a
temp=temp+rem;
sum=sum+rem;
i++;
rem=0;
numb=numb/10;

}


printf("%ld appears in here for %ld time \n",in,count);

printf("inverse is %ld",temp);

}

No comments:

Post a Comment