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 =)

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>);

tnx..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.