We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.

www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

# cs201 first assignment complete solution due date 25-11-13

Do not copy this, try yourself. this is only for idea purpose. i added this in pdf and word format both.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

Views: 3316

Attachments:

### Replies to This Discussion

koi correct solution send kar do

Rubab .ccp ek file format jese hai k .doc Microsoft Word ki format ha.

.ccp file Dev C++ se open hoti and banti hai.

/Cs201 assignment No. 1 complete solution according to requirement
#include<iostream>
#include <cstdlib>
using namespace std;

int main()
{

double far_temp, kel_temp, cal_temp;

char opt, select;

cout " ************* Temprature Conversion Calculator *************";

cout "\n\n Please enter the temprature unit for which you want the conversion ";

cout "\n 1. F for Fahrenheit to Celsius and Kelvin";

cout "\n 2. C for Celsius to Fahrenheit and Kelvin";

cout "\n 3. K for Kelvin to Fahrenheit and Celsius";

do // for do, while loop
{

cout "\n\n Please enter you Option: ";

cin >> opt;

switch(opt) // switch statements

{

case 'f':

case 'F':
{

cout " Enter temprature in Farhenheit: ";

cin >> far_temp;

cal_temp = (far_temp - 32) * 5/9;

kel_temp = (far_temp + 459.67) * 5/9;

cout " Celcius =" cal_temp;

cout "\n Kelvin =" kel_temp;

break;
}

case 'c':

case 'C':
{
cout " Please enter temprature in Celcius: ";

cin >> cal_temp;

kel_temp = cal_temp + 273.15 ;

far_temp = cal_temp * 9/5 + 32;

cout " Farhenheit =" far_temp;

cout "\n Kelvin =" kel_temp;

break;
}

case 'k':

case 'K':
{

cout " Please enter temprature in Kelvin: ";

cin >> kel_temp;

cal_temp = kel_temp - 273.15 ;

far_temp = (kel_temp - 273.14) * 9/5 + 32;

cout " Celcius =" cal_temp;

cout "\n Farhenheit =" far_temp;
break;
}

default:
{
cout "\n Please enter valid option (C, F, K)";

}

cout"\n Do you want to continue (y/n):";
cin>>select;

if(select=='n') //for exit

{
system("pause");
}

}
while(select=='y'); //for loop

}

This code uses concept of function call. Following is the code and i am uploading the cpp file.

# include <iostream>
# include <cstdlib>
using namespace std;

float F, C, K;
char unit, start;

void selection()
{
switch (unit)
{
case 'F':
case 'f':
cout "Enter temperature in Fahrenheit " ; cin >> F;
C = (F - 32) * 5/9;
K = (F + 459.67) * 5/9;
cout   "Celsius = " C endl;
cout   "Kelvin = " K endl;
break;
case 'K':
case 'k':
cout "Enter temperature in Kelvin " ; cin >> K;
C = K - 273.15;
F = K    * 9/5 - 459.67;
cout   "Celsius = " C endl;
cout   "Fahrenheit = " F endl;
break;
case 'C':
case 'c':
cout "Enter temperature in Celsius " ; cin >> C;
F = C * 9/5 + 32;
K = C + 273.15;
cout   "Fahrenheit = " F endl;
cout   "Kelvin = " K endl;
break;
default: cout "Enter a valid unit \n";
}
}

int main()
{

cout "*************Temperature Conversion Calculator*************" endl endl;
cout "Please enter the temperature unit for which you want the conversion" endl;
cout "1. F for Fahrenheit to Celsius and Kelvin \n";
cout "2. C for Celcius to Fahrenheit and Kelvin \n";
cout "3. K for Celsius and Fahrenheit \n";

selection();
do
{
cout "Do you want to continue (y/n) " ; cin >> start;
if (start =='y') {selection();}
}
while(start == 'y');

system("pause");
}

#include<iostream>
#include<conio.h>
using namespace std;
main()
{
float a,b,c;
char i,select;

cout"*************Temprature Conversion Caculator*************"endl;
cout"Please enter the temprature unit for which you want the conversion"endl;
cout"1. F for fahrenheit to celcius and kelvin"endl;
cout"2. C for celcius to farenheit and kelvin"endl;
cout"3. K for celcius and fahrenheit"endl;
coutendl;
do
{

cin>>i;
switch(i)
{
case'C':
case'c':
{
cout"Enter the Temperature in Celsius:"endl;
cin>>a;
b=1.8*a+32.0;
c=a+273;
cout"Temperature in Fahrenheit is "bendl;
cout"Temperature in Kelvin is "cendl;

break;
}
case'F':
case'f':
{
cout"Enter the Temperature in Fahrenheit:";
cin>>b;
a=(b-32.0)/1.8;
c=(b+459.67)*5/9;
cout"Temperature in Celsius is "aendl;
cout"Temprature in Kelvin is"cendl;

break;
}
case 'k':
case 'K':
{
cout"Enter the temprature in kelvin:";
cin>>c;
b=c-459.67*9/5;
a=c-273.15;
cout"Temprature in Fahrenheit is"bendl;;
cout"Temprature in Celcius is"aendl;

break;
}

default:
{
cout "\n Please enter valid option (C, F, K)";
}
}

cout"\n Do you want to continue (y/n):";
cin>>select;

if(select=='n') //for exit

{
system("pause");
}

}
while(select=='y'); //for loop

}

Dear All,

Most of the solutions have not done following things:

• Repetition Structures (Loops)
• indented and well commented

So do the above things in your assignments.

Dear All,

This is my suggestion only.

The Dev C++ version for x86/32 bit windows shared in LMS is beta version.

You can use the other version 5.4.2 It is stable and fast. If you need any help regarding this version he/she can contact me.

Regards,

J

## Latest Activity

Haram Iftekhar updated their profile
5 minutes ago
8 minutes ago
8 minutes ago
9 minutes ago
9 minutes ago
+M.Tariq Malik added a discussion to the group ENG001 Elementary English

### ENG001 Elementary English GDB No 01 Fall 2020 Solution / Discussion Last Date: 04-12-2020

9 minutes ago
Shahid Abbas, Alina nawaz, Sikandar and 8 more joined Virtual University of Pakistan
10 minutes ago
20 minutes ago
Sobia Abbasi posted a status
"mgt 610 ki gdb ki ksi ny"
20 minutes ago
Sobia Abbasi, Misbii Khan and иαвєєℓ αнмє∂ joined +M.Tariq Malik's group

23 minutes ago
35 minutes ago
35 minutes ago

1

2

3