0% found this document useful (0 votes)
87 views5 pages

Program To Print Addition of Two Numbers

The document contains code for two C programs. The first program reads two numbers as input, adds them together, and prints the sum. The second program reads a number as input, calculates the sum of the cubes of its digits, and prints whether the number is Armstrong or not based on the comparison of the input number and calculated sum.

Uploaded by

anon-417140
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views5 pages

Program To Print Addition of Two Numbers

The document contains code for two C programs. The first program reads two numbers as input, adds them together, and prints the sum. The second program reads a number as input, calculates the sum of the cubes of its digits, and prints whether the number is Armstrong or not based on the comparison of the input number and calculated sum.

Uploaded by

anon-417140
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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