Message from discussion
c++ coding
Received: by 10.216.135.222 with SMTP id u72mr963278wei.3.1335772834140;
Mon, 30 Apr 2012 01:00:34 -0700 (PDT)
X-BeenThere: virtaul-pakistan@googlegroups.com
Received: by 10.216.199.225 with SMTP id x75ls3529583wen.9.gmail; Mon, 30 Apr
2012 00:59:52 -0700 (PDT)
Received: by 10.180.92.170 with SMTP id cn10mr1547715wib.3.1335772792983;
Mon, 30 Apr 2012 00:59:52 -0700 (PDT)
Received: by 10.216.114.73 with SMTP id b51msweh;
Sun, 29 Apr 2012 10:40:04 -0700 (PDT)
Received: by 10.204.157.134 with SMTP id b6mr1121331bkx.5.1335721204065;
Sun, 29 Apr 2012 10:40:04 -0700 (PDT)
Received: by 10.204.157.134 with SMTP id b6mr1121330bkx.5.1335721204022;
Sun, 29 Apr 2012 10:40:04 -0700 (PDT)
Return-Path: <mc120200...@vu.edu.pk>
Received: from mail-bk0-f47.google.com (mail-bk0-f47.google.com [209.85.214.47])
by gmr-mx.google.com with ESMTPS id k15si16004645bks.0.2012.04.29.10.40.03
(version=TLSv1/SSLv3 cipher=OTHER);
Sun, 29 Apr 2012 10:40:04 -0700 (PDT)
Received-SPF: neutral (google.com: 209.85.214.47 is neither permitted nor denied by best guess record for domain of mc120200...@vu.edu.pk) client-ip=209.85.214.47;
Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.214.47 is neither permitted nor denied by best guess record for domain of mc120200...@vu.edu.pk) smtp.mail=mc120200...@vu.edu.pk
Received: by bkcjm2 with SMTP id jm2so270565bkc.34
for <virtaul-pakistan@googlegroups.com>; Sun, 29 Apr 2012 10:40:03 -0700 (PDT)
d=google.com; s=20120113;
h=mime-version:x-originating-ip:in-reply-to:references:date
:message-id:subject:from:to:content-type:x-gm-message-state;
bh=1GX9uksXYqXQtbNHD7n4ICr38aWWk3cL+UIxswcvdtc=;
b=cMiMgDwtYWneTSeMynC5YYRAL5sR6F0TZyhbg8c/dyRjzJfhVRE3A/IziuQTA9/jCs
GSMXPSVobAR4A6wNXO/wvwN13dKl5YK/fcS3BI/muImMVsAs9nEUkQ/b32mvHVoLm9AC
NZOwXdjoFIGeCec0BDE230+qZdibD0uHGEucDuqTsBhR8Szu5B1nOPLaymzZbHvynK63
jt0wWNukkCA2LFei1IYs7t7UOLxB4JFbZYKivUWy9e6tUuG3JG47VWmTfRAzw9bxAbIv
w/v2c7J+nPX2cL0la/465Oks0FBXEQjidXju/it7pYxCKu4+lrXqk6Q/mjFZPY0FGJUA
5iBQ==
MIME-Version: 1.0
Received: by 10.204.155.92 with SMTP id r28mr4376391bkw.130.1335721203683;
Sun, 29 Apr 2012 10:40:03 -0700 (PDT)
Received: by 10.204.53.142 with HTTP; Sun, 29 Apr 2012 10:40:03 -0700 (PDT)
X-Originating-IP: [182.177.205.232]
In-Reply-To: <CADVrf0f_QHofXwu+tkfvWux0wxUR+st6GDCHZnx1UpLwDLX...@mail.gmail.com>
References: <CAOT_VT6X6dkkvmcN49yjV7MOZQuT=4E4C5WqGnoYDF6DHE_...@mail.gmail.com>
<CADVrf0f_QHofXwu+tkfvWux0wxUR+st6GDCHZnx1UpLwDLX...@mail.gmail.com>
Date: Sun, 29 Apr 2012 22:40:03 +0500
Message-ID: <CAOT_VT66hDfVdyrb5MSX4oVXef896gaBqbMZb-VZkBETMD_...@mail.gmail.com>
Subject: Re: [virtualinspire.com] c++ coding
From: mc120200982 Aqsa <mc120200...@vu.edu.pk>
To: virtaul-pakistan@googlegroups.com
Content-Type: multipart/alternative; boundary=0015175cf7d6dd51a504bed4d3f0
X-Gm-Message-State: ALoCoQm4NXuYlmvQzkQWrintSlxzYvljHfOwZET7AiQCBMzm8zht/uG+D6SEOi0Dhcn8UJOIlqmP
--0015175cf7d6dd51a504bed4d3f0
Content-Type: text/plain; charset=ISO-8859-1
Thanks a lot Naseer bro you help me is main mind karyn ki kya bat hy agr
mind karna hota to mail kyu karti
On Sun, Apr 29, 2012 at 7:05 PM, mc100400855 Naseer Ahmed Khan <
mc100400...@vu.edu.pk> wrote:
> AOA
>
> your section of code that i highlighted in red is OK but not efficient
> what if all the values are already sorted then still these nested loops
> will carry on their work so make a separate swap routine and declare a
> variable flag=0 if on comparison value is greater than the value ahead it
> (i guess you probably want values in increasing order) so when a comparison
> is made then set the flag=1 that mean you need another outer loop iteration
> That is why the wise men created a bubblesort algo.
> hope you didn't take it to heart just take it to mind sis.
> regards
> On Sun, Apr 29, 2012 at 10:48 AM, mc120200982 Aqsa <mc120200...@vu.edu.pk>wrote:
>
>> i make this coding plaz check
>> #include<cstdlib>
>> #include<iostream>
>> void high_Tenp(int[],int);
>> void low_ten(int[]);
>> void Average_tenp(int[],int);
>> using namespace std;
>> int main(int argc, char*argv[])
>> {
>> cout<<"\t\t*****************"<<endl
>> <<"\t\t TEMPRATURE CALCULATION SYSTEM"<<endl
>> <<"\t\t************************************"<<endl<<endl;
>> int n;
>> cout<<"Enter the number of consecutive days to read theritemperature:";
>> cin>>n;
>> int x[n];
>> int i,j,temp;
>> for(i=0;i<n;i++)
>> {
>> cout<<endl<<"Enter temperature for day"<<i+1<<":";
>> cin>>x[i];
>> }
>> for(i=0;i<n;i++)
>> {
>> for(j=0;j<n-1;j++)
>> {
>> if(x[j] > x[j+1])
>> {
>> tmp = x[j];
>> x[j]=x[j+1];
>> x[j+1]=tmp;
>> }
>> }
>> }
>> Average_Tenp(x,n);
>> high_Tenp(x,n);
>> low_Tenp(x);
>> system("pause");
>> }
>> voidhigh_Tenp(inta[],intarraysize)
>> {
>> cout<<"The Higest Temprature is:"<<a[arraysiz-1]<<endl;
>> }
>> void low_Tenp(inta[])
>> {
>> int b=0;
>> cout<<"The Lowest Temprature is:"<<a[b]<<endl;
>> }
>> void Average_Tenp(int a[],int arraysize)
>> {
>> int i;
>> double c=0;
>> for (i = 0 ; i<arraysize; i ++)
>> {
>> c=c+a[i];
>> }
>> c=c/i;
>> cout<<endl<<"The Average Tempure is:"<<c<<endl;
>> }
>> void swap(int*x,int*y)//function using pointers to interchange the values
>> {
>> int tmp;
>> if(*x>*y)
>> {
>> tmp = * x;
>> * x = * y;
>> * y = tmp;
>> }
>> }
>>
>>
>> --
>> Contact Owner Id: zainaliza...@gmail.com
>>
>> www.virtualinspire.com
>>
>> If you want domain and web hosting. Also contact with me.
>>
>> 5000 per year with cpanel and domain name free with it.
>>
>
> --
> Contact Owner Id: zainaliza...@gmail.com
>
> www.virtualinspire.com
>
> If you want domain and web hosting. Also contact with me.
>
> 5000 per year with cpanel and domain name free with it.
>
--0015175cf7d6dd51a504bed4d3f0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Thanks a lot Naseer bro you help me is main mind karyn ki kya bat hy agr mi=
nd karna hota to mail kyu karti<br><br><div class=3D"gmail_quote">On Sun, A=
pr 29, 2012 at 7:05 PM, mc100400855 Naseer Ahmed Khan <span dir=3D"ltr"><=
;<a href=3D"mailto:mc100400...@vu.edu.pk" target=3D"_blank">mc100400855@vu.=
edu.pk</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">AOA<div><br></div><div>your section of code =
that i highlighted in red is OK but not efficient what if all the values ar=
e already sorted then still these nested loops will carry on their work so =
make a separate swap routine and declare a variable flag=3D0 if on comparis=
on value is greater than the value ahead it (i guess you probably want valu=
es in increasing order) so when a comparison is made then set the flag=3D1 =
that mean you need another outer loop iteration That is why the wise men cr=
eated a bubblesort algo.</div>
<div>hope you didn't take it to heart just take it to mind sis.</div><d=
iv>regards<br><div class=3D"gmail_quote"><div class=3D"im">On Sun, Apr 29, =
2012 at 10:48 AM, mc120200982 Aqsa <span dir=3D"ltr"><<a href=3D"mailto:=
mc120200...@vu.edu.pk" target=3D"_blank">mc120200...@vu.edu.pk</a>></spa=
n> wrote:<br>
</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div><div class=3D"h5"><div>i make thi=
s coding plaz check</div><div>#include<cstdlib></div><div>#include<=
;iostream></div>
<div>void high_Tenp(int[],int);</div>
<div>void low_ten(int[]);</div><div>void Average_tenp(int[],int);</div><div=
>
using namespace std;</div><div>int main(int argc, char*argv[])</div><div>{<=
/div><div><span style=3D"white-space:pre-wrap"> </span>cout<<"\t=
\t*****************"<<endl</div><div><span style=3D"white-space:=
pre-wrap"> </span><<"\t\t TEMPRATURE CALCULATION SYSTEM"<=
;<endl</div>
<div><span style=3D"white-space:pre-wrap"> </span><<"\t\t*******=
*****************************"<<endl<<endl;</div><div><spa=
n style=3D"white-space:pre-wrap"> </span>int n;</div>
<div><span style=3D"white-space:pre-wrap"> </span>cout<<"Enter t=
he number of consecutive days to read theritemperature:";</div><div><s=
pan style=3D"white-space:pre-wrap"> </span>cin>>n;</div>
<div><span style=3D"white-space:pre-wrap"> </span>int x[n];</div><div><span=
style=3D"white-space:pre-wrap"> </span>int i,j,temp;</div><div><span style=
=3D"white-space:pre-wrap"> </span>for(i=3D0;i<n;i++)</div>
<div><span style=3D"white-space:pre-wrap"> </span>{</div><div><span style=
=3D"white-space:pre-wrap"> </span>cout<<endl<<"Enter temp=
erature for day"<<i+1<<":";</div>
<div><span style=3D"white-space:pre-wrap"> </span>cin>>x[i];</div><d=
iv><span style=3D"white-space:pre-wrap"> </span>}</div><div><span style=3D"=
white-space:pre-wrap"> </span><font color=3D"#ff0000">for(i=3D0;i<n;i++)=
</font></div>
<div><font color=3D"#ff0000"><span style=3D"white-space:pre-wrap"> </span>{=
</font></div><div><font color=3D"#ff0000"><span style=3D"white-space:pre-wr=
ap"> </span>for(j=3D0;j<n-1;j++)</font></div><div><font color=3D"#ff000=
0"><span style=3D"white-space:pre-wrap"> </span>{</font></div>
<div><font color=3D"#ff0000"><span style=3D"white-space:pre-wrap"> </span=
>if(x[j] > x[j+1])</font></div><div><font color=3D"#ff0000"><span style=
=3D"white-space:pre-wrap"> </span>{</font></div><div><font color=3D"#ff00=
00"><span style=3D"white-space:pre-wrap"> </span>tmp =3D x[j];</font></d=
iv>
<div><font color=3D"#ff0000"><span style=3D"white-space:pre-wrap"> </spa=
n>x[j]=3Dx[j+1];</font></div><div><font color=3D"#ff0000"><span style=3D"wh=
ite-space:pre-wrap"> </span>x[j+1]=3Dtmp;</font></div><div><font color=
=3D"#ff0000"><span style=3D"white-space:pre-wrap"> </span>}</font></div>
<div><font color=3D"#ff0000"><span style=3D"white-space:pre-wrap"> </span>=
}</font></div><div><font color=3D"#ff0000"><span style=3D"white-space:pre-w=
rap"> </span>}</font></div><div><span style=3D"white-space:pre-wrap"> </spa=
n>Average_Tenp(x,n);</div>
<div><span style=3D"white-space:pre-wrap"> </span>high_Tenp(x,n);</div><div=
><span style=3D"white-space:pre-wrap"> </span>low_Tenp(x);</div><div><span =
style=3D"white-space:pre-wrap"> </span>system("pause");</div>
<div>}</div><div>voidhigh_Tenp(inta[],intarraysize)</div><div>{</div><div><=
span style=3D"white-space:pre-wrap"> </span>cout<<"The Higest Te=
mprature is:"<<a[arraysiz-1]<<endl;</div>
<div>}</div><div>void low_Tenp(inta[])</div><div>{</div><div><span style=3D=
"white-space:pre-wrap"> </span>int b=3D0;</div><div><span style=3D"white-sp=
ace:pre-wrap"> </span>cout<<"The Lowest Temprature is:"<=
<a[b]<<endl;</div>
<div>}</div><div>void Average_Tenp(int a[],int arraysize)</div><div>{</div>=
<div><span style=3D"white-space:pre-wrap"> </span>int i;</div><div><span st=
yle=3D"white-space:pre-wrap"> </span>double c=3D0;</div>
<div><span style=3D"white-space:pre-wrap"> </span>for (i =3D 0 ; i<array=
size; i ++)</div><div><span style=3D"white-space:pre-wrap"> </span>{</div><=
div><span style=3D"white-space:pre-wrap"> </span>c=3Dc+a[i];</div>
<div><span style=3D"white-space:pre-wrap"> </span>}</div><div><span style=
=3D"white-space:pre-wrap"> </span>c=3Dc/i;</div><div><span style=3D"white-s=
pace:pre-wrap"> </span>cout<<endl<<"The Average Tempure is=
:"<<c<<endl;</div>
<div>}</div><div>void swap(int*x,int*y)//function using pointers to interch=
ange the values</div><div>{</div><div><span style=3D"white-space:pre-wrap">=
</span>int tmp;</div><div><span style=3D"white-space:pre-wrap"> </span>if(=
*x>*y)</div>
<div><span style=3D"white-space:pre-wrap"> </span>{</div><div><span style=
=3D"white-space:pre-wrap"> </span>tmp =3D * x;</div><div><span style=3D"wh=
ite-space:pre-wrap"> </span>* x =3D * y;</div>
<div><span style=3D"white-space:pre-wrap"> </span>* y =3D tmp;</div><div><=
span style=3D"white-space:pre-wrap"> </span>}</div><div>}</div></div></div>=
<span><font color=3D"#888888"><div><span style=3D"white-space:pre-wrap"> </=
span></div>
<div><span style=3D"white-space:pre-wrap"> </span>=A0</div><div><br></div>=
<div class=3D"im">
<p></p>
-- <br>
Contact Owner Id: <a href=3D"mailto:zainaliza...@gmail.com" target=3D"_blan=
k">zainaliza...@gmail.com</a><br>
=A0<br>
<a href=3D"http://www.virtualinspire.com" target=3D"_blank">www.virtualinsp=
ire.com</a><br>
=A0<br>
If you want domain and web hosting. Also contact with me.<br>
=A0<br>
5000 per year with cpanel and domain name free with it.<br>
</div></font></span></blockquote></div><br></div><div class=3D"HOEnZb"><div=
class=3D"h5">
<p></p>
-- <br>
Contact Owner Id: <a href=3D"mailto:zainaliza...@gmail.com" target=3D"_blan=
k">zainaliza...@gmail.com</a><br>
=A0<br>
<a href=3D"http://www.virtualinspire.com" target=3D"_blank">www.virtualinsp=
ire.com</a><br>
=A0<br>
If you want domain and web hosting. Also contact with me.<br>
=A0<br>
5000 per year with cpanel and domain name free with it.<br>
</div></div></blockquote></div><br>
--0015175cf7d6dd51a504bed4d3f0--