Professional Documents
Culture Documents
Program To Print Addition of Two Numbers
Program To Print Addition of Two Numbers
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 :-
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 :-
*/