The if keyword is used to execute a statement or block only if a condition is fulfilled. Its form is:if (condition) statementWhere condition is the expression that is being evaluated. If this condition is true, statement is executed. If it is false, statement is ignored (not executed) and the program continues right after this conditional structure.For example, the following code fragment prints x is 100 only if the value stored in the x variable is indeed 100:if (x == 100) cout << "x is 100";If we want more than a single statement to be executed in case that the condition is true we can specify a block using braces { }:if (x == 100){ cout << "x is "; cout << x;}We can additionally specify what we want to happen if the condition is not fulfilled by using the keyword else. Its form used in conjunction with if is:if (condition) statement1 else statement2For example:if (x == 100) cout << "x is 100";else cout << "x is not 100";prints on the screen x is 100 if indeed x has a value of 100, but if it has not -and only if not- it prints out x is not 100.The if + else structures can be concatenated with the intention of verifying a range of values. The following example shows its use telling if the value currently stored in x is positive, negative or none of them (i.e. zero):if (x > 0) cout << "x is positive";else if (x < 0) cout << "x is negative";else cout << "x is 0";Remember that in case that we want more than a single statement to be executed, we must group them in a block by enclosing them in braces { }.
C++
Topic: Object oriented programming
Explain about conditional structure if and else ?
Browse random answers:
What is abstraction?
what are the disadvantages of copy constructor??
What will happen if I say delete this ?
What are the different types of polymorphism?
Differences of C and C++Could you write a small program that will compile in C but not in C++ ?
A positive integer entered through the keyboard. Write a function to obtain the prime factors of this number.For example : prime factors of 24 are 2,2,2 and 3,, where as prime factor of 35 are 5
What do you meant by active and passive objects?
Can the structures contain the constructor?If yes, then how?
plz tell how can i attach oracle database with c++?
Anything wrong with this code?T *p = new T[10];delete p;
What do you mean by analysis and design?
Q1.write C++ program to accept a string and display ascii value letter by letter then display sum of all ascii values.Q2.write C++ program to accept 20 nos and then display max & min.
How can i create a program in C++which would input 5 random numbers, then it would arrange them in an ascending order, in descending order, from highest to lowest value and from lowest to highest value?
What do you mean by binding of data and functions?
Differentiate Aggregation and containment?
How to write a program to read sequences of integer from keyboard.program should sum all even and odd numbers?
How can we define a dynamic memory allocation in UNIX operating system?
What is the object-oriented design,inheritance and dynamic polymorphism in c++?
What are 2 ways of exporting a function from a DLL?
What is an object?
How can I make application program using c++, that means, execute as application that have setup and install on other computer run with out c++ compiler?
Write a program on abstract class. ?
Given an integer N>0,write a recursive c++ function that writes the integer 1,2,.......N ?
For the following C program#define AREA(x)(3.14*x*x)main(){float r1=6.25,r2=2.5,a;a=AREA(r1);printf("Area of the circle is %f", a);a=AREA(r2);printf("Area of the circle is %f", a);}What is the Output?
What is encapsulation?
What are the steps involved in designing?
How can you tell what shell you are running on UNIX system?
List out some of the object-oriented methodologies.
Write programs using nested loops to produce the following design:** * ** * * * ** * **
Write a c++ programme in order to find the day you born,such that the programmer will take your birth date (day-month-year)?
Imagine you're maintaining a big project which is having 50k+ lines of code and as part of enhancements, you received a request to add a functionality in one of the .cpp files. For this, you need to add a new function. How do you write a new fucntion without adding a prototype to the header file (because, if you add prototype in the headerfile, the compiler has to compile all the other files). So, the requirement is not to touch the header file but add functionality in the cpp file. How do you add?
What are the defining traits of an object-oriented language?
What is multithreading?
Will it execute or not?
Explain about structure of a program ?
Explain about conditional structure if and else ?
Explain about iteration structures (loops) ?