Code:#include <conio.h> #include <stdio.h> int main() { int i,total,array[3]={4,5,6}; total=0; for(i=0;i<3;i++) { total+=array[i]+array[i+1]; printf("%i",(total)); } getch(); } /*above is incorrect, but how do I do 4+5+6=15?*/
Code:#include <conio.h> #include <stdio.h> int main() { int i,total,array[3]={4,5,6}; total=0; for(i=0;i<3;i++) { total+=array[i]+array[i+1]; printf("%i",(total)); } getch(); } /*above is incorrect, but how do I do 4+5+6=15?*/
You just need to add the current array element to the total.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
how?
sweet.