Simple calculations : int Calculation « Data Type « C Tutorial






#include <stdio.h>

int main(void)
{
  int Total_Pets;
  int Cats;
  int Dogs;
  int Ponies;
  int Others;

  Cats = 2;
  Dogs = 1;
  Ponies = 1;
  Others = 46;

  Total_Pets = Cats + Dogs + Ponies + Others;

  printf("We have %d pets in total", Total_Pets);  /* Output the result */
  return 0;
}
We have 50 pets in total








2.5.int Calculation
2.5.1.Simple calculations
2.5.2.Divide Integer
2.5.3.Sum the integers from 1 to a user-specified number
2.5.4.If both operands i1 and i2 are integers, the expression i1/i2 provides integer division