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

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-Assignment # 1(Complete Solution)

+ 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: 5320

Attachments:

### Replies to This Discussion

Dear Fellows,

All of you are requested, Please post Only One Discussion for Current Assignment/GDB/Online Quiz and everyone reply/share/discussed his/her data on that same discussion, so that all members get solution & discuss easily on Current Assignment/GDB/Online Quiz.

So please don’t post two or more discussions for one Current Assignment/GDB/Online Quiz, hope you’ll understand and cooperate with us.

http://vustudents.ning.com/group/cs201introductiontoprogramming/for...

My assignment solution please check if any error :)

# Preview of the Assignment:

cs201 correct solution

/*
BY Aamir Hafeez mc150400753@vu.edu.pk
remove the above type your name and roll no
This program will calculate the area of rectangle and trapezoid
*/
#include <iostream>
using namespace std;

double rectangleArea(double width, double length);
double trapezoidArea(double base1, double base2, double height);

main()
{
char c;

do{
int choice;
cout "\nEnter 1 to calculate area of rectangle\n";
cout "Enter 2 to calculate area of trapezoid\n";
cin >> choice;

if(choice == 1)
{
double width, length;
cout "Enter the width of rectangle: ";
cin >> width;
cout "Enter the length of rectangle: ";
cin >> length;
cout "The area of rectangle is: " rectangleArea(width, length);

}

else if(choice == 2)
{
double base1, base2, height;
cout "Enter the base1 of trapezoid: ";
cin >> base1;
cout "Enter the base2 of trapezoid: ";
cin >> base2;
cout "Enter the height of trapezoid: ";
cin >> height;
cout "\nThe area of trapezoid is: "
trapezoidArea(base1, base2, height);

}

cout "\n\nDo you want to do another calculation: ";
cin >> c;
} while( c == 'y' || c == 'Y');

return 0;
}

double rectangleArea(double width, double length)
{
return (width * length);
}

double trapezoidArea(double base1, double base2, double height)
{
return ( height *( (base1 + base2) / 2) );
}

lstn m not  getting error in  namespace em not getting it
the error is nested name specifier before name space
what is ths??

#include <iostream>
#include <stdlib.h>
using namespace std;

void AreaRect()
{
float x, y;
cout"\n\nEnter width of rectangle: ";
cin>>x;
cout"Enter length of rectangle: ";
cin>>y;
cout"The Area of rectangle is: "x*yendlendl;

}

float AreaTrap()
{
float base1, base2, height, tarea
cout"\nEnter base 1 of trapezoid: ";
cin>>base1;

cout"Enter base 1 of trapezoid: ";
cin>>base2;

cout"Enter height of trapezoid: ";
cin>>height;
tarea = ((base1+base2)/2)*height; // formula Area= ((b1 + b2)/2)*h
cout"\nThe Area of Trapezoid is: "tareaendlendl;
}

main() // functio to choice
{
int choice;
char repeat = 'y';
while(repeat=='y' || repeat=='Y')
{
cout"\n\nEnter 1 to calculate area of Rectangle"endl;

cout"Enter 2 to calculate area of Trapezoid\n"endl;

cin>>choice;

switch(choice)
{
case 1:
AreaRect();
break;

case 2:
AreaTrap();
break;
default:

cout"\nInvalid Choice!\n";
}
cout"Do you want another calculation?: ";
cin>>repeat;
}
system("pause");
}

please any body will help me to do cs201 assignment 1 due on 5

dec

## Latest Activity

18 minutes ago
24 minutes ago
26 minutes ago
26 minutes ago
26 minutes ago
★彡[ꜱʜʏɴᴀ]彡★ liked zohaib iftikhar's blog post ...* LUQMA ...*
26 minutes ago
★彡[ꜱʜʏɴᴀ]彡★ liked Amna Bhatti's discussion GDB of ISL 201 fall 2021
27 minutes ago
★彡[ꜱʜʏɴᴀ]彡★ liked Fahad Shahid's discussion Online Job
27 minutes ago
27 minutes ago
Mᴀʟɪᴋ0ᴏᴏ updated their profile
35 minutes ago
Mᴀʟɪᴋ0ᴏᴏ liked Mᴀʟɪᴋ0ᴏᴏ's profile
37 minutes ago
1 hour ago

1

2

3

4