Question

In: Computer Science

Do in c++ programming languages Question 1: Solve the complete Question with all parts and subparts....

Do in c++ programming languages

Question 1: Solve the complete Question with all parts and subparts.

a) What do you understand by the term DATA TYPE?

b) Is it possible to replace for loop with a while loop. Justify your answer with reasoning and example.

c) Draw a flow chart for Do-While loop for controlled/uncontrolled infinite loop iterations.

d) Write down a function prototype that takes an array and its length as an argument and also return the same array by reversing the position of elements.

e) As you know that “the base address or the starting address of any array is its name”. Keeping this information, answer

i) Why the first index of any array always starts from zero. Although it points to the first location of an array.

ii) The reason why the last index is always one less than array length is “the first index starts from zero”. Does it seems to be a correct reason justify.

iii) What is the offset address of any array NAMED AS ARR1 who starting address is A011234h.

iv) Can you find the offset address of the 6th element of array given in 3? If its data type is INT. 5. What is the offset address of last element of an array stated in 3? If the length of array is 5 and data type is char.

Note: If you are not able to do complete question with parts and its subparts so kindly never do any single part ( i need complete question with proper answers.

Solutions

Expert Solution

a)

Data type of any variable is a special type of attribute which lets the compiler or interpreter know what kind of data user will be storing in it.

eg - int,char,float,double

b)

In a for loop 3 steps take place (i) initiation -In this step a variable is assigned with initial value (ii) condition-After initiation, condition checking takes place so if condition satisfies (iii) Increment or decrement of variable takes place

So if we can implement all these three steps in while loop we can replace for loop with while loop

and we can do it actually

initializing the variable with initial value before while loop

inside while(condition) checks for condition and inside the body of loop increment or decrement takes place

eg-

for(int i=0;i<23;i++)

{

printf(4);

}

this code with while loop will be like

int i=0;

while(i<23)

{

printf(4);

i++;

}

int *reverse(int arr[],int n)

{

int temp;

for(int i=0;i<=n/2;i++)

{

temp=arr[i];

arr[i]=arr[n-i-1];

arr[n-i-1]=temp;

}

return(arr);

}


Related Solutions

QUESTION 1 Which of the following programming languages does NOT support parametric polymorphism? Java C++ Python...
QUESTION 1 Which of the following programming languages does NOT support parametric polymorphism? Java C++ Python C# 10 points    QUESTION 2 Which of the following programming languages does NOT support operator overloading? C# Python C C++ 10 points    QUESTION 3 In a language that allows nested subprograms, the programming language has to choose a referencing environment for the executing the passed subprogram when a subprogram is passed as a parameter. Which of the following is NOT a choice?...
1.In C++, C#, Java. Discuss string operations functions, with examples. Then make Comparison of programming languages  ...
1.In C++, C#, Java. Discuss string operations functions, with examples. Then make Comparison of programming languages   2.String and StringBuffer (C#, Java) with examples.
1. Answer all parts (a) – (c) of this question. [8 marks] In the context of...
1. Answer all parts (a) – (c) of this question. [8 marks] In the context of the money multiplier explain how lending activity of banks is related to the money supply of an economy. How can the central bank of a given economy control the money supply? [9 marks] “Inflation is always and everywhere a monetary phenomenon”. Provide an economic explanation for that statement. Is the statement more likely to be true in the long-run, in the short-run, or in...
1. Answer all parts (a) – (c) of this question. [8 marks] In the context of...
1. Answer all parts (a) – (c) of this question. [8 marks] In the context of the money multiplier explain how lending activity of banks is related to the money supply of an economy. How can the central bank of a given economy control the money supply? [9 marks] “Inflation is always and everywhere a monetary phenomenon”. Provide an economic explanation for that statement. Is the statement more likely to be true in the long-run, in the short-run, or in...
Please solve all parts of the following question on MATLAB. 1. Penn State football travels to...
Please solve all parts of the following question on MATLAB. 1. Penn State football travels to Ohio State to play the Buckeyes on Nov 23, 2019. The official capacity of Ohio Stadium is 104,944. Let’s say that the stadium is filled at the beginning of the game, but every time Penn State scores a touchdown half of the fans leave. How many touchdowns does Penn State have to score until there is just one fan left in the stadium? a....
Correct C++ function and main files separately for the following question and its subparts. 1-aGiven a...
Correct C++ function and main files separately for the following question and its subparts. 1-aGiven a matrix of integers, count the amount of times each number 0-9 appears. Print out your results on one line in the following form: 0:number of zeros;1:number of ones;2:number of twos;3:number of threes;4:number of fours;5:number of fives;6:number of sixes;7:number of sevens;8:number of eights;9:number of nines; For example, if you are passed an identify matrix, it contains 12 zeros and 4 ones and no other numbers...
C++ programming Complete the code to input and store all the information in the structure Book:...
C++ programming Complete the code to input and store all the information in the structure Book: title, author, year and pages. Complete the function print() with arguments and code to print a Book variable in the following format: Book title: <title> Book author: <name> Published in <year> Number of pages: <pages> #include <iostream> using namespace std; struct Book { string title; string author; string year; int pages; }; void print(/*arguments*/) { //Complete function } int main() { //Declare structure variable...
Please make sure to complete all parts of the question and to show all work used...
Please make sure to complete all parts of the question and to show all work used to compute the answer so I can see how the answer was found. A five-year annuity of 10 $5,230 semiannual payments will begin nine years from now, with the first payment coming nine and a half years from now. If the discount rate is 10 percent compounded monthly, what is the value of this annuity five years from now? What is the value three...
Please solve all parts of the following question. Please show all work and all steps. 1a.)...
Please solve all parts of the following question. Please show all work and all steps. 1a.) Solve x' = x + 3y + 2t y' = x - y + t^2 1b.) Solve x' + ty = -1 y' + x' = 2 1c.) Solve x' + y = 3t y' - tx' = 0
Java, Python, and C++ are three of the most useful programming languages to learn. Compare the...
Java, Python, and C++ are three of the most useful programming languages to learn. Compare the functionalities of all three programming languages. Why would you choose one language over another? Provide code examples demonstrating their usefulness in a real-world scenario.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT