c++ basic coding

Hey guys!
I am basically very new to this C++.
Let me just jump into my silly questions, hoping to get answers.

1. why do we declare int size
2. void comes with array? (what is void anyways)
3. function prototype? have to use with array? (array?)

Pls help me!
I am using codeBlocks just for the info
Last edited on
Could you maybe rephrase and expand your questions? They don't make any sense to me, as they are.
1) You have to declare the type of any variable. Otherwise, the compiler won't know what type of data that variable is storing.

2) Huh? That question makes no sense to me. "void" is used as a type, where no variable is actually being defined - usually, when declaring that a function doesn't return anything. void has nothing to with arrays.

3) I have no idea what you're asking here.
Thanks for the reply guys and really sorry for the weird questions. Let me just post the question given to me and hopefully you guys can get me through this.
Question.
Write a complete C++ program that can read a line of characters (read character by character), and store only the digit characters ‘0’,’1’,…,’9’ inside an array named as "WORD". Place a null character ‘\0’ after last read digit. Then, compute and display the multiply result for all digits that store in the array of WORD. Use a multiply function to do this question.

For example 1, if the program reads the following line, “1Word3Word5”, the program should store in array WORD with the following: ‘1’ ‘3’ ‘5’ ‘\0’ . The sum for all digits of this sentence is 9.
Example Output 1:
Enter a line of characters: 1Word3Word5
The line of characters only contain the number of 1, 3, 5.
Sum for the 1 * 3 * 5 is = 15

For example 2, if the program reads the following line, “hiHi12330”, the program should store in array WORD with the following: ‘1’ ‘2’ ‘3’‘3’ ‘0’ ‘\0’ . The sum for all digits of this sentence is 21.
Example Output 2:
Enter a line of characters: hiHi12990
The line of characters only contain the number of 1, 2, 3, 3, 0.
Sum for the 1 * 2 * 3 * 3 * 0 is = 18

Basically this is the task given to me, I am not asking you guys to solve for me this completely. Just a brief idea or explanation on how I can get this done!

tQ
do it step by step,

first:
Write a complete C++ program that can read a line of characters (read character by character)


when that works, modify it to
store only the digit characters ‘0’,’1’,…,’9’ inside an array named as "WORD"


when that works modify it to
Place a null character ‘\0’ after last read digit


when that works modify i tto
compute and display the multiply result for all digits that store in the array of WORD


use the examples as extra info to see if your program is on the right track.
Topic archived. No new replies allowed.