C Programming Tutorial - How to Calculate Interest



Hey Guys,

Lets see how we can calculate page views for a website and interest rate in a bank.

Lets say we want to calculate page view for a website

#include <stdio.h>

int main()
{
    int pageViews = 0;
    
    pageViews = pageViews + 1; 
    
    printf("Page views: %d \n", pageViews);
    
    pageViews = pageViews + 1;
    
    printf("Page views: %d \n", pageViews);
    
    pageViews = pageViews + 1;
    
    printf("Page views: %d \n", pageViews);
}

Lets make it an interest calculator.


#include <stdio.h>

int main()
{
   
    float balance = 1000.00;
    
    balance *= 1.1 ; {This is a short hand way of writing  balance = balance*1.1;}
 
     printf("balance: %f \n", balance);

Lets say everytime when it print this out that is one year or something. So lets see after three years what would be the interest?.
      
      balance *= 1.1 ;
    
      printf("balance: %f \n", balance);
      
      balance *= 1.1 ;
    
      printf("balance: %f \n", balance);
}


Comments