Monday, November 15, 2010

A program to read an integer no recursively until the user enters negative numbers

/* Write a program to read an integer no recursively until the user enters negative numbers
   and find the sum of nos entered by the user
   Developed by : Malhar Vora
   Developed on : 15-11-2010
   Development Status : Completed and tested
   Email : vbmade2000@gmail.com
   WebSite : www.malhar2010.blogspot.com
********************************************************************************************/
int a=0,sum=0;

void main()
{
   printf("Enter no :");
   scanf("%d",&a);

   if(a<0)
   {
 printf("Sum is : %d",sum);
 return;
   }
   else
   {
 sum = sum + a;
   }
   main();

}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.