heolp help!
i'm new to c++ and i need help to write a new program
i guess a simple one that counts numbers would be good
i know printf() and some other functions
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <stdio.h>
int main()
{
int y = 0;
need more stuff here :)
printf("\nthe number in y is %d\n", y);
return 0;
}
#include <iostream> // Not <stdio.h>
int main()
{
int y[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int runningTotal{ 0 };
std::cout << "Adding all the elements in the array 'y'...\n"; // cout, not printf.
for (auto count : y) // Use a range for loop to count all the elements in the array (C++ 11)
{
std::cout << count << std::endl;
runningTotal += count;
}
std::cout << "The total is " << runningTotal << std::endl;
}
#include <stdio.h>
int main()
{
int y[] = { 4, 6, 11, 12, 23, 42, 24, 16 };
int p;
int o;
o = y[0];
for (p = 1; p < 8; p++)
{
o = y[p] + o;
}
printf("\n\nThe amount of y[] unsized array elements added is %d\n\n", o);
return 0;
}