<span> change the behavior of the program I think</span>
Answer:
The program in Python is as follows:
apples = int(input("Apples: "))
people = int(input("People: "))
apples%=people
print("Remaining: ",apples)
Explanation:
This gets the number of apples
apples = int(input("Apples: "))
This gets the number of people to share the apple
people = int(input("People: "))
This calculates the remaining apple after sharing the apple evenly
apples%=people
This prints the calculated remainder
print("Remaining: ",apples)
Answer:
The function in C++ is as follows:
int isSorted(int ar[], int n){
if ( || ){
return 1;}
if ( < ){
return 0;}
return isSorted(ar, n - 1);}
Explanation:
This defines the function
int isSorted(int ar[], int n){
This represents the base case; n = 1 or 0 will return 1 (i.e. the array is sorted)
if ( || ){
return 1;}
This checks if the current element is less than the previous array element; If yes, the array is not sorted
if ( < ){
return 0;}
This calls the function, recursively
return isSorted(ar, n - 1);
}