Jump to content

Structura while


Guest baTTLe4u
 Share

Recommended Posts

Guest baTTLe4u

Salut, va rog explicatimi si mie structura while si do while cu multe exemple cine se pricepe in c !?

si puteti sa-mi explicati ce se gaseste in:

#include "conio.h" ?

Link to comment
Share on other sites

Pai in primu rand, structura while este o structura repetitiva in C++ si este regasita in biblioteca conio.h !

 

Structura while este asemanatoare structurii repetitive, FOR, singura diferenta este ca FOR-ul se foloseste atunci cand stim de cate ori se repeta instructiunea iar WHILE cand nu stim.

 

Forma generala este:

 

while (conditie)

{

instructiunile care se repeta

}

 

Instructiunile din while sunt executate atata timp cat conditia dintre paranteze este adevarata...

 

Un mic exemplu:

 

void main ()
{
       //Declaram o variabila a si ii dam valoarea 0
       int a = 0;

       //Cat timp a este egal cu 0, a creste cu 1
       while (a == 0)
       {
             a = a+1; 
       }
}

 

Conditia din while in exemplu este adevarata o singura data fiindca la prima repetare a devine 1. In concluzie, blocul de instructiuni se repeta o singura data.

 

 

 

Sunt multe de zis...sper ca te-am ajutat !

Edited by Szerky
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.