Skip to main content

Practice Problems #1.

Below are 6 problems related to arrays, decision making statements etc.

No solution will be provided for these problems except Bonus Problem.

Problem 1 - Your program should print 

  1. "The weather is Good" if today's temperature is greater than 20 degree and less than 25 degree, 
  2. "The weather is little cold" if today's temperature is less than 20 degree and greater than 15 degree, 
  3. "The weather is cold" if today's temperature is less than 15 degree.
  4. "The weather is little warm" if today's temperature is greater than 25 degree but less than 30 degree.
  5. "The weather is warm" if today's temperature is greater than greater than 30 degree and less than 40 degree.
  6. "The weather is really hot" if today's temperature is greater than 40 degree.
Try, to not to confuse yourself with all these statements and print accordingly to the condition matching the user's input.


Problem 2 - Try to create a program with following rules -
  1. In main method you should create an array dynamically and allocate memory for it.
  2. Create a function which take the array as argument and try to initialize this array in the function with the distinct multiples of number 2, but not in main method.

Problem 3 - Create a program which should take two, 2 dimensional arrays as input, and output there product. (Assume that both the arrays are square matrices and both arrays has same dimensions)


Problem 4 - Write a program to calculate the volume of a cube and area of a square.


Problem 5 - Try to create a program with following rules - 
  1. Create and initialize an array in your main method/function and pass it a function.
  2. The function should return an array (Return means really return).
  3. The returned array and array which is defined in main must have same sizes.
  4. The returned array must have every values 2 times the array sent as a paramter.
  5. The array sent as a parameter should not be modified.

Bonus Problem - Create a Program to print fibonacci sequence. The program should print 93 fibonacci numbers(let's see if you figure out, what I want you to).
Solution to Problem.

If you still don't get, what is wrong in bonus problem, comment below and I will try to clear that concept too.

Before watching this tutorial, please try to solve them by yourself.

Comments

Post a Comment

Popular posts from this blog

Number Systems (Binary and Decimal Number Systems).

We are surrounded with Numbers.  For example a human being has 2 ears, 2 legs(generally) and one nose. These all are nothing but numbers. Now, one might ask why do we need to study numbers for c++ programming. Let me answer this one first. In the previous blog I discussed that every computer works on machine language i.e. 0s and 1s, everyone know 0 and 1 are numbers. Ok, done, But what the word "Systems" doing here? What is meant by number systems. Let's see. We all have studied about the numbers from 0 to 9 i.e. 0,1,2,3,4,5,6,7,9 and we very well know that every other number can be derived from these number except infinity(no one knows what's that). for example one thousand twenty two is 1022.  This number system that we have studied is called Decimal Number System.  Why, Decimal? Because this number system contains 10 different symbols.  (In Greek Deca or Deka means 10 and this words is derived from Deca/Deka). Ok, Now we know what is decimal number system and why...

C++ Arrays, functions, pointers and references.

In the previous section, I have discussed about  Built-in Data Types in depth. Now, let's taste the flavors of Variables and literals, with a in depth introduction. Variables A Variable provide us with named memory storage, i.e. a storage in our so called RAM with a particular name (usually we give the name), We can write, modify and use this storage with the help of associated name (variable). Each variable in C++ is associated with some specific data type, like Built-in data types that we previously discussed.  There are mainly two values that are associated with any variable. RValues. LValues. Let's see what all these means. RValues - We know that a variable has some data associated with it, and we can read, write this data, this data that we read and write is termed as RValue. You can also think of RValues as Read Values or as a simple trick from me to you, you can think of as the right side values of assignment opeartor(=) . LValues - We Also know that these variables ...