Suma numerelor impare

08 Apr

Modificând puţin programul anterior, obţinem algoritmul care calculează suma primelor n numere impare…

De exemplu dacă n = 5 atunci suma = 1+3+5+7+9 = 25.

int main()
{ int n,i,contor=0,suma=0;
 cout<<"n="; cin>>n;
 { suma=suma+i;
 contor++; }
 cout<<"Suma primelor "<<n<<" numere impare este: "<<suma;
 getch(); }
About these ads
1 Comment

Posted by on April 8, 2011 in Uncategorized


Tags: ,

One response to “Suma numerelor impare


    April 8, 2012 at 12:46

    Mersi pe asta l-am inteles


Lasă un comentariu

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: