Answer:
e. 4
Explanation:
The code segment will not work as intended if the value of the variable val is 4. This is because the while loop is comparing the value of the variable val to the value of each element within the numList. Since there is no element that is bigger than or equal to the number 4, this means that if the variable val is given the value of 4 it will become an infinite loop. This would cause the program to crash and not work as intended.
In C, you deal with a string always via a pointer. The pointer by itself will not allocate memory for you, so you'll have to take care of that.
When you write char* s = "Hello world"; s will point to a "Hello world" buffer compiled into your code, called a string literal.
If you want to make a copy of that string, you'll have to provide a buffer, either through a char array or a malloc'ed bit of memory:
char myCopy[100];
strcpy(myCopy, s);
or
char *myCopy;
myCopy = (char*)malloc( strlen(s) + 1 );
strcpy(myCopy, s);
The malloc'ed memory will have to be returned to the runtime at some point, otherwise you have a memory leak. The char array will live on the stack, and will be automatically discarded.
Not sure what else to write here to help you...
Answer:
Program is in C++
Explanation:
C++ Code
1) By using For Loop
void forLoopFunction(int value){
for(int start=value; start>0; start--){
cout<<start<<endl;
}
}
Explanation
Start for loop by assigning the loop variable to parameter value and condition will be that loop variable will be greater then 0 and at the end decrements the loop variable.
2) By usin WhileLoop
void whileLoopFunction(int value){
while(value>0){
cout<<value<<endl;
value--;
}
}
Explanation
In while loop first add the condition as variable must be greater then 0 and then print the value with endl sign to send the cursor to next line and at the end of the loop decrements the variable.
It performs the basic arithmetical, logical, and input/output operations of a computer