online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> struct device { int ports; char port_type; float cost; int cpu_cores; int chips; struct { int version; int year; char manufacturer[10]; } make; float current_rating, power_rating; }; // Do NOT modify any code above. // Declare the global device array dev_database here and // store the specified information on the 5 devices struct device dev_database[5] = { {5, 'B', 73.45, 4, 7, {2, 2015, "Intel"}, 3.1, 1.2}, {5, 'A', 70.00, 2, 5, {1, 2010, "Micron"}, 2.0, 1.5}, {5, 'B', 65.00, 2, 5, {1, 2011, "Intel"}, 3.0, 1.5}, {5, 'C', 80.00, 8, 7, {1, 2015, "Motorola"}, 2.5, 1.0}, {5, 'A', 70.00, 2, 5, {3, 2012, "Intel"}, 3.0, 1.3} }; void print_device(int index) { printf("-----\n"); printf("%s (%d) Version %d\n\n",dev_database[index].make.manufacturer,dev_database[index].make.year,dev_database[index].make.version); printf("Ports = %d x %c\n",dev_database[index].ports,dev_database[index].port_type); printf("Cost = $%.2f\n",dev_database[index].cost); printf("CPU cores = %d\n",dev_database[index].cpu_cores); printf("Chips = %d\n",dev_database[index].chips); printf("Rating = %.1fA / %.1fW\n",dev_database[index].current_rating,dev_database[index].power_rating); } void database_info() { printf("Storage size for each device = %d bytes\n",sizeof(dev_database[0])); printf("Number of devices that can be stored = %d\n",sizeof(dev_database)/sizeof(dev_database[0])); } void search_port_type(char port_type) { int index[5],counter,i; for (i=0; i<5; i++){ if (dev_database[i].port_type == port_type ){ index[counter]=i; counter++; } } printf("%d device(s) found!\n",counter); for (i=0; i<counter; i++){ print_device(index[i]); } return; } void search_current_power(float current, float power) { int index[5],counter,i; for (i=0; i<5; i++){ if (dev_database[i].current_rating == current && dev_database[i].power_rating == power){ index[counter]=i; counter++; } } printf("%d device(s) found!\n",counter); for (i=0; i<counter; i++){ print_device(index[i]); } return; } int main() { int option; printf("EDD\n1 = Get database information\n2 = Search by port type\n3 = Search by current / power ratings\n=====\nInput: "); scanf("%d",&option); if (option ==1){ database_info(); } else if (option == 2){ char port_type; printf("Specify port type: "); scanf("%c\n",&port_type); search_port_type(port_type); } else if (option ==3){ float current_rating, power_rating; printf("Specify current and power: "); scanf("%f %f\n",&current_rating, &power_rating); search_current_power(current_rating, power_rating); } else{ printf("Invalid input!\n"); }; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue