0

guys i'm asking for some help..i have an asgnment bout c++..our prof ask us to give 2 examples ech of the simple if prog, if else, if else if, switch, while, do while and for loop...tnx

i'm just a freshmen student of bsit..tnx =)

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Pamella
0

i hope this codes will help you or somehow will give you idea on how to manipulate looping and conditional programs that you will make.

Conditional statements
- is a feature of programming language which perform
different computations or actions depending on whether a programmer
specified condition evaluates to true or false.

statement:

if(<condition>)
{
 <arguments/statements>;
}

else if (<condition>)
{
 <arguments/statements>;
}

else
{
 <statement>;
}

if/else statement:

{
 if(<condition>)
    <statement>;
}

switch(variable)
 {
   case <value1>:
	   <statement>;
	  break;
   case <value2>:
	   <statement>;
	  break;
   default:
	   <statement>;
 }

Loo0ping statement - is a sequence of stateent which is specified once but which may 
		     be carried out several times in succesion.

for(<initialization>;<condition>;<++/-->)
{
  <statement>;
}

while
	while(<condition>)
	      {
	       <statement>
	      }


do-while

 do {
      <statement>
    }
while (<condition>);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.