C++ problem. Please Help i am a newbie and i am badly stuck. PLEASE SOMEBODY HELP!!?

FUJITSU

New member
Joined
Nov 22, 2010
Messages
4
Reaction score
0
Points
1
Age
44
Location
USA
http://www.flickr.com/photos/59737449@N08/6268765558/
please see this link. I have tried writing the codes my self for question no1 and question no 2.
Code for question one works but if i want to do it using a formula i dont know what that would be. Coming to question 2 this code doesn't work. I have tried a lot but no luck. can somebody help me. i am stuck and i need your help please help me. Also i dont know how to do the third one if you know then please give it a try.I am pasting codes for question no 1 and 2

Question no 1

//Program for listing factors from 1-20

#include <iostream.h> // Including Library. Allows program to output data to the screen
#include <conio> // Including Library since it contains getche() to hold the screen

int main() // Funtion main begins program execution

{
cout<<"\tNumbers\t\t\tFactors\n\n";
cout<<"\t1\t\t\t1\n\t2\t\t\t2\n\t3\t\t\t3\n";
cout<<"\t4\t\t\t2,4\n\t5\t\t\t5\n\t6\t\t\t2,3,6\n";
cout<<"\t7\t\t\t7\n\t8\t\t\t2,4,8\n\t9\t\t\t3,9\n";
cout<<"\t10\t\t\t2,5,10\n\t11\t\t\t11\n";
cout<<"\t12\t\t\t2,3,4,6,12\n\t13\t\t\t13\n\t14\t\t\t2,7,14\n";
cout<<"\t15\t\t\t3,5,15\n\t16\t\t\t2,4,8,16\n\t17\t\t\t17\n";
cout<<"\t18\t\t\t2,3,6,9,18\n\t19\t\t\t19\n";
cout<<"\t20\t\t\t2,4,5,10,20\n";



getche();

return 0;
} // End Main Function



Question No 2

//Program to calculate the BMI of a user. Take weight in pounds and height in inches

#include <iostream.h>
#include <conio>

int main()
{
int w,tw,h,th,BMI; //w=wight, tw=temporary weight,h= height, th=temporary height

cout<<"Please Enter your weight in pounds or Kg\t";
cout<< "Is your weight in pounds? (Type Y for yes and N for no)";

if(y);
cout"w";
cin>>w;

else

{
cin>>tw;
w=tw*2.2;
}

cout<<"Please enter your hight in inches or feet\t";
cout<<" Is your height in inches? Type Y for yes and N for no";

if(y);
cout<<"h";

else
{
cout<<"th";
cin>>th;

h=th/12;
}

BMI =(w*703)/h;
cout<< "Your BMI is\t" <<BMI;

getche();
return 0;
}
 
I passed up helping you before because I don't like helping people who keep their Q&As private. But I'm going to help on the factors.

cout<<" Numbers Factors"<<endl;
for( int n=1;n<=20;n++ ) {
...for( div = 2; div<=n; div++ ) {
......if( n%div == 0 ) cout<<div<<",";
...}
...cout<<endl;
}
 
Back
Top