The power of the loop
Java tutorial video taught by Mr. Rightwing
Moderators: Moderators, Junior Moderators
Re: Java tutorial video taught by Mr. Rightwing
A C++ Program to calculate the average of four numbers.
#include<iostream.h>
int main()
{
using namespace std;
float num,sum=0,average;
cout<<"enter the first number\n";
cin>>num;
sum=sum+num;
cout<<"enter the second number\n";
cin>>num;
sum=sum+num;
cout<<"enter the third number\n";
cin>>num;
sum=sum+num;
cout<<"enter the fourth number\n";
cin>>num;
sum=sum+num;
average=sum/4.0;
cout<<"the average of the four numbers is "<<average<<endl;
system("pause");
return 0;
}
#include<iostream.h>
int main()
{
using namespace std;
float num,sum=0,average;
cout<<"enter the first number\n";
cin>>num;
sum=sum+num;
cout<<"enter the second number\n";
cin>>num;
sum=sum+num;
cout<<"enter the third number\n";
cin>>num;
sum=sum+num;
cout<<"enter the fourth number\n";
cin>>num;
sum=sum+num;
average=sum/4.0;
cout<<"the average of the four numbers is "<<average<<endl;
system("pause");
return 0;
}
Re: Java tutorial video taught by Mr. Rightwing
\\A C++ Program For Temperature Conversion using if else statement.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
using namespace std;
int main()
{
char temptype;
float temp,ctemp,ftemp;
cout<<"enter the temperature to be converted";
cin>>temp;
cout<<"enter F if the temperature you entered is in fahrenheit "<<endl;
cout<<"or C if the temperature you entered is in celcius "<<endl;
cin>>temptype>;
cout<<setiosflags(ios::fixed)
<<setiosflags(ios::showpoint)
<<setprecision(2);
if(temptype=='f')
{
ctemp=(9.0/5.0)*(temp-32);
cout<<"the equivalent temperature in celcius is "<<ctemp<<endl;
}
else
{
ftemp=5.0/9.0*temp+32;
cout<<"the equivalent temperature in fahrenheit is "<<ftemp<<endl;
}
system("pause");
return 0;
}
A subsequent implementation of this program in dev++ compiler results in this

Uploaded with ImageShack.us]
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
using namespace std;
int main()
{
char temptype;
float temp,ctemp,ftemp;
cout<<"enter the temperature to be converted";
cin>>temp;
cout<<"enter F if the temperature you entered is in fahrenheit "<<endl;
cout<<"or C if the temperature you entered is in celcius "<<endl;
cin>>temptype>;
cout<<setiosflags(ios::fixed)
<<setiosflags(ios::showpoint)
<<setprecision(2);
if(temptype=='f')
{
ctemp=(9.0/5.0)*(temp-32);
cout<<"the equivalent temperature in celcius is "<<ctemp<<endl;
}
else
{
ftemp=5.0/9.0*temp+32;
cout<<"the equivalent temperature in fahrenheit is "<<ftemp<<endl;
}
system("pause");
return 0;
}
A subsequent implementation of this program in dev++ compiler results in this

Uploaded with ImageShack.us]
- Rightwing
- SomaliNet Super
- Posts: 9248
- Joined: Mon Dec 23, 2002 7:00 pm
- Location: Maqaamka lagu xadreeyo MEDED, MEDED
- Contact:
Re: Java tutorial video taught by Mr. Rightwing
Maansha allah sxb pm isoo dir. Waxaad tahay dadka la rabo in wax u qabtaan wadankiiyo. Maanta aduunkoo dhami software ayuu ku xidhanyahay.
Cheer RW
Cheer RW
Re: Java tutorial video taught by Mr. Rightwing
Another one which calculates the distance b.w two points in space by utilizing the power of the infinite loop.
#include<iostream.h>
#include<math.h>
int main()
{
float x1,x2,y1,y2;
float distance;
int count=1;
cout<<"This program allows you to calculate the distance b/w two points :\n";
while(count<=1)
{
cout<<"Enter the first co-ordinate of the points"<<endl;
cin>>x1;
cout<<"Enter the second co-ordinate of the points"<<endl;
cin>>x2;
cout<<"Enter the third co-ordinate of the points"<<endl;
cin>>y1;
cout<<"Enter the fourth of co-ordinate of the points"<<endl;
cin>>y2;
distance=sqrt(pow(x2-x1,2.0)+pow(y2-y1,2));
cout<<"The distance b/w these points equals :"<<distance<<"\n";
count--;
}
system("pause");
return 0;
}
The program

Uploaded with ImageShack.us
#include<iostream.h>
#include<math.h>
int main()
{
float x1,x2,y1,y2;
float distance;
int count=1;
cout<<"This program allows you to calculate the distance b/w two points :\n";
while(count<=1)
{
cout<<"Enter the first co-ordinate of the points"<<endl;
cin>>x1;
cout<<"Enter the second co-ordinate of the points"<<endl;
cin>>x2;
cout<<"Enter the third co-ordinate of the points"<<endl;
cin>>y1;
cout<<"Enter the fourth of co-ordinate of the points"<<endl;
cin>>y2;
distance=sqrt(pow(x2-x1,2.0)+pow(y2-y1,2));
cout<<"The distance b/w these points equals :"<<distance<<"\n";
count--;
}
system("pause");
return 0;
}
The program

Uploaded with ImageShack.us
Re: Java tutorial video taught by Mr. Rightwing
Thanks,Check Your PM bro....Maansha allah sxb pm isoo dir. Waxaad tahay dadka la rabo in wax u qabtaan wadankiiyo. Maanta aduunkoo dhami software ayuu ku xidhanyahay.
Cheer RW
- Rightwing
- SomaliNet Super
- Posts: 9248
- Joined: Mon Dec 23, 2002 7:00 pm
- Location: Maqaamka lagu xadreeyo MEDED, MEDED
- Contact:
Re: Java tutorial video taught by Mr. Rightwing
Addoow wrote:Thanks,Check Your PM bro....Maansha allah sxb pm isoo dir. Waxaad tahay dadka la rabo in wax u qabtaan wadankiiyo. Maanta aduunkoo dhami software ayuu ku xidhanyahay.
Cheer RW
Adoow
yr desktop is messy sxb.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 20 Replies
- 2857 Views
-
Last post by abdalla11
-
- 0 Replies
- 511 Views
-
Last post by Rightwing
-
- 3 Replies
- 643 Views
-
Last post by Basra-
-
- 1 Replies
- 463 Views
-
Last post by Rightwing
-
- 0 Replies
- 897 Views
-
Last post by Rightwing
-
- 0 Replies
- 973 Views
-
Last post by Rightwing
-
- 3 Replies
- 1159 Views
-
Last post by afisoone
-
- 4 Replies
- 957 Views
-
Last post by anzeloti
-
- 4 Replies
- 2676 Views
-
Last post by Rightwing
-
- 0 Replies
- 542 Views
-
Last post by afisoone