C Program to
Add reversed number with Original Number
#include
#include
#include
#include
int main()
{
int num1,
num2;
char
str[10];
printf("nEnte the Number : ");
scanf("%d",
&num1);
sprintf(str, "%d", num1);
strrev(str);
num2 =
atoi(str);
printf("\nReversed + Original Num = %d ", num1 + num2);
return(0);
}
Output
Ente the Number : 123
Reversed + Original
Num = 444
C Program to
Reverse the digits of a number in 3 Steps
#include
#include
#include
#include
int main()
{
int num1,
num2;
char
str[10];
printf("\nEnte the Number : ");
scanf("%d", &num1);
sprintf(str, "%d", num1);
strrev(str);
num2 = atoi(str);
printf("\nReversed Number : ");
printf("%d", num2);
return
(0);
}
Output
Enter the Number : 123
Reversed Number : 321
C Program to add
digits of the number using single statement
#include
#include
int main()
{
int
number = 12354;
int sum =
0;
for
(; number > 0; sum += number % 10, number /= 10);
printf("\nSum of the Digits : %d", sum);
}
Output
15
C Program to
Demonstrate Printf inside Another Printf Statement
#include
#include
int main()
{
int num=1342;
printf("%d",printf("%d", printf("%d",num)));
return (0);
}
Output
134241
No comments:
Post a Comment