Displaying Source Code(s)
|
|
TO FIND SUM OF GIVEN INTEGER UNTIL WILL GET SINGLE DIGIT WITHOUT
USING ANY CONDITIONAL STATEMENT.
--------------------------------------------------------------------------------
Description : TO FIND THE SUM OF GIVEN INTEGER UNTIL SINGLE
DIGIT
# include <stdio.h>
# include <conio.h>
main()
{ int number;
clrscr();
printf("enter the value for n<BR>);
scnaf("%d",&number);
/* MY FIRST LOGIC*/
printf("%d",(number-1)%9+1);
/* MY SECOND LOGIC*/
printf("%d",9-((18-number%9)/9 * 9));
/* MY THIRD LOGIC */
printf("%d",n%9+(9-n%9)/9 * 9);
getch();
} |
|
|