I know this is going to be something of a silly slip or oversight on my behalf, but I can't get the array in this to print out correctly. When I run the code and put in my inputs, I get seemingly random numbers. For example, number of rooms was 1 wattage of lights was 2 hours used was 2 TV/computers was 2
The output I got was 3930804. What did I miss?
#include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <ctype.h> int main() { int room[20] = {0.0}; int i; int rooms = 0; char option = 0; int lights[20]; int hrsUsed[20]; int Telly_Computer[20]; printf("Enter number of rooms"); scanf_s("%d", &rooms); for(i=0;i<rooms;i++) { printf("input wattage of lights"); scanf_s("%d", (lights+i)); printf("input number of hours use/day (average)"); scanf_s("%d", (hrsUsed+i)); printf("input number of TV/Computers"); scanf_s("%d", (Telly_Computer+i)); } printf("%d \n", lights); }
scanf_sright.