I need this program to take three items for input then give three outputs for results. Is this program I wrote practical? its bug free and it builds but something in the style I dont like it seems I need some sort of nested loop in here not sure - and yes it's homework - but I just need advice and hints to improve it (that's if it needs to be improved)
I hope i did the code blocks rightCode:#include <iostream> #include <string> using namespace std; int main() { // initialization of Variables string input1; string input2; string input3; string veg [3]; string fruit [3]; string dairy [3]; //initialization veg [0] = "carrot"; veg [1] = "broccoli"; veg [2] = "tomato"; fruit [0] = "apple"; fruit [1] = "orange"; fruit [2] = "milk"; dairy [0] = "milk"; dairy [1] = "cheese"; dairy [2] = "kiwi"; //if statement cout<<"Enter 3 Items"<<endl; cin>>input1; cin>>input2; cin>>input3; for(int i = 0;1 <3; i++) { if (input1 == veg [i]) cout<<input1<<"Is a Vegetable" <<endl; else if(input1 == dairy[i]) cout<<input1<<"Is a Dairy Product"<<endl; else if(input1 == fruit [i]) cout<<input1<<"Is a Fruit Product"<<endl; else if(input2 == veg [i]) cout<<input2<<"Is a Vegetable"<<endl; else if(input2 == dairy[i]) cout<<input2<<"Is a Dairy Product"<<endl; else if(input2 == fruit [i]) cout<<input2<<"Is a Fruit Product"<<endl; else if(input3 == veg [i]) cout<<input3<<"Is a Vegetable"<<endl; else if(input3 == dairy [i]) cout<<input3<<"Is a Dairy Product"<<endl; else if(input3 == fruit [i]) cout<<input3<<"Is a Fruit Product"<<endl; return 0; } }