Tuesday, 4 October 2016

To find sum of digits of a 3 digit no.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,e,f;
cout<<“Enter the three digit no. “;
cin>>a;
b=a%10;
c=a/10;
d=c%10;
e=a/100;
f=b+d+e;
cout<<“Sum of the digits = “<<f;
getch();
}

No comments:

Post a Comment

Basic Implementation of Array as a Pointer

#include<iostream.h> #include<conio.h> void main() { clrscr();   int arr[5];   cout<<"Enter 5 nos. ";   f...