Skip to main content

Posts

Showing posts from August 22, 2020

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  "The weather is Good" if today's temperature is greater than 20 degree and less than 25 degree,  "The weather is little cold" if today's temperature is less than 20 degree and greater than 15 degree,  "The weather is cold" if today's temperature is less than 15 degree. "The weather is little warm" if today's temperature is greater than 25 degree but less than 30 degree. "The weather is warm" if today's temperature is greater than greater than 30 degree and less than 40 degree. "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 foll

The Loop Statements.

In this slide we try to figure out what are loops and why they are important and using them with a couple of examples. After that we will try to understand some other statements like Break , Continue and Goto statement. Loops are used to perform some task repeatedly until some condition remains true. for e.g. take this blog, we will keep learning C++ until we don't get to a level, where we can write basic C++ program very easily. Let's discuss these, one by one - for loop Statement. while loop Statement. do-while loop Statement. Let's Start our discussion. for loop for loop is one of the most widely used loop, and I myself most of time use for loop. for loop is used when you very  well know that how much repetitions you need to perform. For example, counting numbers upto 100, and the time we reach hundred we stop. Syntax is shown in the below snippet -  #include<iostream> using namespace std; int main () { for ( initialization ; condition ; increment/decrement