Operator sequence : Operator Rank « Language Basics « C / ANSI-C






Operator sequence

#include <stdio.h>

int main(void)
{
  int rooms, len, width, total;
  int i;

  printf("Number of rooms? ");
  scanf("%d", &rooms);

  total = 0;
  for(i = rooms; i > 0; i--) {
    printf("Enter length: ");
    scanf("%d", &len);

    printf("Enter width: ");
    scanf("%d", &width);

    total = total + len * width;
  }
  printf("Total square footage: %d", total);

  return 0;
}


           
       








Related examples in the same category