Mega Code Archive

 
Categories / C / Code Snippets
 

Operator sequence

#include <stdio.h> int main(void) { int rooms, len, width, total; int j; printf("Number of rooms? "); scanf("%d", &rooms); total = 0; for(j = rooms; j > 0; j--) { printf("Enter length: "); scanf("%d", &len); printf("Enter width: "); scanf("%d", &width); total = total + len * width; } printf("Total square footage: %d", total); return 0; }