Write functions with the following headers: int* readVector(char fname[], int &s
ID: 3885565 • Letter: W
Question
Write functions with the following headers: int* readVector(char fname[], int &size;) This function should read values from the file and save them in a 1D array (vector) and return a pointer to it. The first element in the file is number of values followed by the values. Note that size is passed to the function by reference, so you have to define it in the caller. void print Vector(char fname[], int *M, int size) This function should print the content of the 1D array to the output filet. void VectorMult (int *A, int *B, int *R, int size) The function perform a scalar multiplication the vector with the vector and save the result in vector. (element by element multiplication) Test the function with a program that reads two files "input1.txt" and "input2.txt" and save the results in pointers A and B, call the VectorMult to calculate the vector R then finally print the result in the file "output.txt".Explanation / Answer
#!/usr/bin/python
def reverse(number):
num = number
rev = 0
rem;
while num != 0:
rem = num % 10
rev = rev * 10 + rem
num = num / 10
return rev
def isPalidrome(number):
rev = reverse(number)
if rev == number:
print 'It is a palidrome'
else:
print 'It is not a palindrome'
if __name__ == "__main__":
number = int(input("Enter a number :"))
isPalidrome(number)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.