238
11-listing.
Berilgan n gacha sonlar yigindisi
Output:
void main()
{ long n,i=1,s=0;
cin >>n;
while (i<= n )
s+=i++;
cout<<” s=”<< s; }
n=5;
s=15;
Bu dasturda
s+=i++
ifoda
s=s+i; i=i+1
ifodalarga ekvivalentdir.
Quyidagi dastur to nuqta bosilmaguncha kiritilgan simvollar va qatorlar soni
hisoblanadi:
12-listing.
Output:
void main()
{ long nc=0, nl=0;
char c=``;
while (c!= `.` )
{++nc; cin >>c;
if (c ==`\n`) ++nl; };
cout<<("%1d\n", nc);
cout <<"\n satrlar="<< nl<<”simvollar=”<< nc; }