#include<stdio.h>
#include<conio.h>
main()
{
int k=0,total=0;
int n,a,num;
clrscr();
printf("\n How many digits?"):
scanf("%d",&n);
printf("\n Enter the number:");
scanf("%d",&num);
while(num>0&&k!=n)
{
a=num%10;
num=num/10;
k++;
if(k==1||k==n)
total=total+a;
}
printf("\n Total is:%d",total);
getch();
}
OUTPUT:
How many digits? 3
Enter the number: 124
Total is: 5
Dinesh Thakur is a Columinist and designer with strong passion and founder
of Computer Notes. if you have any ideas or any request Find Dinesh Thakur on
Google+