Skip to content

devs-aparna/Expense-Calculator-Using-C-program

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Expense-Calculator-Using-C-program

A C program to create an expense calculator using recursive functions and pointer to array.

  #include<stdio.h>
  int total_expenses(int *cost,int n);
  int main()
  {
   int n=10;
   int cost[50];
   printf("Enter the expenses:\n");
   for(int i=0;i<10;i++)
  {
    printf("Enter expense %d:\n",i+1);
    scanf("%d",&cost[i]);
   }
   int *ptr;
   ptr=cost;

   int result=total_expenses(ptr,10);
   printf("Your total expenses are: %d\n",result);
   return 0;
  }
  
  int total_expenses(int *cost,int n)
  {
   if(n==0)
   {
    return 0; 
   }
  else
  {
   return cost[n-1]+total_expenses(cost,n-1);
  }
  }

About

A C program to create an expense calculator using recursive functions and pointer to array.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published