Please show me the path of this coding

This is the coding;
#include <iostream>
using namespace std;

int getdata_two(int c[],int startcnt, int endcnt);

main(){
int a[30]= {0,1,2,3,4,5,6......29}
int startcnt [6] = {11,11,19,19,24,24}, endcnt[6]={16,16,23,23,27,27},dataval=68;

if (dataval % 2 ==0)
dataval=getdata_one(a,startcnt[0],endcnt[0]);
else if (dataval % 2 ==1)
dataval=getdata_two(a,startcnt[1],endcnt[1]);

switch (dataval % 2){
case 0:
dataval=getdata_three(a,startcnt[2],endcnt[2]);
break;
case 1:
dataval=getdata_four(a,startcnt[3],endcnt[3]);
}

int getdata_two(int c[],int startcnt, int endcnt){
int datacnt=endcnt;
while (startcnt<endcnt){
datacnt+=c[startcnt];
startcnt++;
}
return datacnt;
}


//
1)My first question,
if [(dataval % 2 ==0)
dataval=getdata_one(a,startcnt[0],endcnt[0]);
else if (dataval % 2 ==1)
dataval=getdata_two(a,startcnt[1],endcnt[1]);

this is function call right? Now the condition fulfilled is (dataval % 2 ==0), its gonna call function definition ---->
int getdata_two(int c[],int startcnt, int endcnt){
int datacnt=endcnt;
while (startcnt<endcnt){
datacnt+=c[startcnt];
startcnt++;
}
return datacnt;
}

2) What is meant by datacnt = endcnt? Is it transfer the number of array which is 6 or the content inside the array?

3) FOR ---> while (startcnt < endcnt), whats the condition that its trying to compare to? is it the array number which is (6<6) or the total content inside array startcnt and endcnt which is 108 and 132 respectively?

4) After it carried out the function definition,it will continue the operation which is ---->
switch (dataval % 2){
case 0:
dataval=getdata_three(a,startcnt[2],endcnt[2]);
break;
case 1:
dataval=getdata_four(a,startcnt[3],endcnt[3]);
}
right? Why did it break tho? Thanks for answering my question :)
Line 6: main() must return type int.

1)
this is function call right?

You have two function calls. getdata_one() and getdata_two(). get_dataone() is not declared or implemented anywhere in your program.

Now the condition fulfilled is (dataval % 2 ==0), its gonna call function definition ---->
int getdata_two

No. It's going to attempt to call getdata_one().

2)
What is meant by datacnt = endcnt?

What ever value is stored in endcnt will be stored in datacnt.

3)
whats the condition that its trying to compare to?

The condition is exactly what it says. The while loop will execute as long as startcnt is less than endcnt.

4)
it will continue the operation which is

Yes. Again getdata_three() and getdata_four() are not declared or implemented anywhere in your program.

Why did it break tho?

Are you asking what the break statements do? Or are you asking why didn't your program run?

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Topic archived. No new replies allowed.