Does a simple calculation using the values of the variables - C Language Basics

C examples for Language Basics:Variable

Description

Does a simple calculation using the values of the variables

Demo Code

#include <stdio.h>

int main(void) {
  int total;/*from   w ww  .j a  v  a2 s . co  m*/
  int cats;
  int dogs;
  int ponies;
  int others;

  cats = 4;
  dogs = 3;

  ponies = 5;
  others = 6;

  total = cats + dogs + ponies + others;

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

Related Tutorials