C Progarm to print Individual Digits

#include<stdio.h>
#include<conio.h>
main( )
{
int x,y,z,w;
clrscr( );
printf ("Enter a two digit number :");
scanf ("%d", &x);
y=x/10;
z=x%10;
w=y+z;
printf ("sum of individual digits of given numbers  %d",w);
getch( );
}

Explanation:
Two digit number is 37
y=37/10; means 37/10, we get 3
z=37%10;means we get remainder value i.e. z=7
w=3+7
Sum is 10

Output:
Run-1

Run-2

No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...