Monday, November 15, 2010

A program to get a no from user and find the sum of its odd digits

/* Write a program to get a no from user  and find the sum of its odd digits
   Developed by : Malhar Vora
   Developed on : 15-11-2010
   Development Status : Completed and tested
   Email : vbmade2000@gmail.com
   WebSite : www.malhar2010.blogspot.com
**********************************************************************************/   
void main()
{

 int a=0,temp=0,sum=0;
 printf("Enter no :");
 scanf("%d",&a);
 if(a==0)
 {
     printf("No can't be 0");
     return;
 }

 //Label test
 test:
  if(a==0)
  {
       printf("Sum is :%d",sum);
       return;
  }

  temp=a%10;
  if(temp%2!=0)
  {
       sum=sum+temp;
  }
  a=a/10;
  goto test;

}

No comments:

Post a Comment