1 for each of the problems listed below write the c program
1 for each of the problems listed below write the c++ program while using WHILE loop structures
A program will display each term in the following sequence
1 -10 100 -1000 10000 -100000 1000000
A program will calculate and display the corresponding celsius temperatures for the given Farenheit ones from 0f to 212 f (hint c=(f-32/1.8)
Solution
Question 1:
#include <iostream>
using namespace std;
int main()
{
int i=1;
while(i <=1000000){
cout<<i<<\" \";
i = i * 10;
}
cout<<endl;
return 0;
}
Output:
sh-4.2$ g++ -o main *.cpp
sh-4.2$ main
1 10 100 1000 10000 100000 1000000
Question 2:
#include <iostream>
using namespace std;
int main()
{
int f=0;
float c;
while(f <=212){
c = (f-32/1.8);
cout<<\"Farenheit: \"<<f<<\" celsius: \"<<c<<endl;
f++;
}
cout<<endl;
return 0;
}
Output:
Farenheit: 183 celsius: 165.222
Farenheit: 184 celsius: 166.222
Farenheit: 185 celsius: 167.222
Farenheit: 186 celsius: 168.222
Farenheit: 187 celsius: 169.222
Farenheit: 188 celsius: 170.222
Farenheit: 189 celsius: 171.222
Farenheit: 190 celsius: 172.222
Farenheit: 191 celsius: 173.222
Farenheit: 192 celsius: 174.222
Farenheit: 193 celsius: 175.222
Farenheit: 194 celsius: 176.222
Farenheit: 195 celsius: 177.222
Farenheit: 196 celsius: 178.222
Farenheit: 197 celsius: 179.222
Farenheit: 198 celsius: 180.222
Farenheit: 199 celsius: 181.222
Farenheit: 200 celsius: 182.222
Farenheit: 201 celsius: 183.222
Farenheit: 202 celsius: 184.222
Farenheit: 203 celsius: 185.222
Farenheit: 204 celsius: 186.222
Farenheit: 205 celsius: 187.222
Farenheit: 206 celsius: 188.222
Farenheit: 207 celsius: 189.222
Farenheit: 208 celsius: 190.222
Farenheit: 209 celsius: 191.222
Farenheit: 210 celsius: 192.222
Farenheit: 211 celsius: 193.222
Farenheit: 212 celsius: 194.222


