Program To Print Addition of Two Numbers

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

PROGRAM TO PRINT ADDITION OF TWO NUMBERS

/* THIS PROGRAM WILL READ 2 NUMBERS AS INPUT AND THEN PRINT THE
SUM OF THOSE TWO NUMBERS AS THE OUTPUT */

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("\n Enter the value of a : ");
scanf("%d",&a);
printf("\n Enter the value of b : ");
scanf("%d",&b);
c=a+b;
printf("\n %d + %d = %d",a,b,c);
getch();
}

/* THE OUTPUT IS :-

Enter the value of a : 25

Enter the value of b : 75

25 + 75 = 100

*/
PROGRAM TO PRINT WHETHER A NO. IS ARMSTRONG OR NOT

/* THIS PROGRAM WILL READ A NUMBER AS INPUT & THEN WILL PRINT ITS
REVERSE AS OUTPUT */

#include<stdio.h>
#include<conio.h>
void main()
{
int n,p,r,c,s=0;
clrscr();
printf("\n Enter the value of n : ");
scanf("%d",&n);
p=n;
while(n>0)
{
r=n%10;
n=n/10;
c=(r*r)*r;
s+=c;
}
printf("\n The sum of cube of digits of n = %d",s);
if(s==p)
printf("\n The number %d is armstrong.",p);
else
printf("\n The number %d is not armstrong.",p);
getch();
}

/* THE OUTPUT IS :-

Enter the value of n : 153


The sum of cube of digits of n = 153
The number 153 is armstrong.

Enter the value of n : 123


The sum of cube of digits of n = 36
The number 123 is not armstrong.

*/

You might also like