Monday, 17 October 2016

HHW Q12. WAP to enter a no. and calculate its some of digits .

#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
long int a,b,c,d,e,f,g,h,i,j;
cout<<"Enter the no. ( max 5 digits) ";
cin>>a;
b=a/10000;
c=a/1000;
d=c%10;
e=a/100;
f=e%10;
g=a/10;
h=g%10;
i=a%10;
j=b+d+f+h+i;
cout<<"Sum of the digits = "<<j;
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...