How To Write Hello World Program In C++ Programming Language

Image
  How To Write a Hello World Program In C++ Programming Language In this post we will look at how a C++ program works. We will try make the example as simple as possible for the beginners so they can easily understand the basics of C++. We will write a simple C++ hello world program in C++ programming language which is considered as the very first program in almost every programming language. A Brief Introduction to the C++ Programming Language C++ is an object oriented programming language and it is an extension to C programming language. C++ is a general purpose programming language and it is also a case-sensitive language. C++ is very powerful programming language it has features of both low level and high level programming languages, and that is why it is called mid level programming language. Hello World program in C++ programming language Above is an example of a simple Hello World program in C++ programming language. Now let us look at the code, and I will take you...

if and if-else statement in C programming language

 If and if-else statements in the C programming language


When we start writing a program, if the program is simple, like adding two numbers, or a Hello World program, we don't need any decision-making in such programs. 

But as the programs get complicated, they become complex, and we must make decisions.

For such programs, we use conditional statements, which help in making decisions. One of the most important conditional statements is

1) if statement

2) if-else statement




What is the if condition?

It is a conditional statement used in almost every programming language. The if statement executes a piece of code based on a specific condition when it is true. When the condition is true, it executes the code with curly brackets.


What is the syntax of if statement 

The if statement has a very simple syntax, as shown below

if (condition)

{

//This piece of code will run if the given condition is true

}


the above line of code tells us that when the condition is true the code written inside curly brackets { } will be executed. Let us understand by an example 




now the if condition will check if num==5 then run the code with in brackets. This above piece of code will only run when the condition is true but what to do if the given condition is false. At this point, the if-else condition comes into the picture.


syntax of if-else condition


if(condition)

{

    // If part of the code

}

else

{

    // else part of code

}




in the above piece of code when the condition is true then the if part of the code will run which is num is equal to 5, and when the if condition is false then the else part will run which prints the message that num is not equal to 5

congratulations we have successfully implemented the if and if-else conditions in our code.






 

Comments

Popular posts from this blog

How if else-if else ladder statement works in C program.

How to add two numbers in C programming language