www.vustudents.ning.com

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

# Final Solution Assignment No. 01 Spring 2013 CS201 Introduction to Programming

#include <iostream>
// <stdlib.h> is for system("pause");
#include <stdlib.h>
int main()

{
using namespace std;
/*

Before submitting please change variables and then save against yourname.cpp
This program is written by Ali Raza Marchal
Student of Virtual University of Pakistan
BSCS[Hons] 2nd Semester
e-Mail ID: bc120403456@vu.edu.pk
Join Group Study: Skype ID: alirazamirchal

Question: Write a program to calculate the slope of the line
that is passing through two points and display 5 nature of slopw.

*/

int X1, X2;
int Y1, Y2;

float slope, SlopX, SlopY;

cout "Enter The X-Coordinate of the starting point = ";
cin >> X1;

cout "Enter The Y-Coordinate of the starting point = ";
cin >> Y1;

cout "Enter the X-Coordinate of the Ending point = ";
cin >> X2;

cout "Enter the Y-Coordinate of the Ending point = ";
cin >> Y2;

SlopX = (X2 - X1);

SlopY = (Y2 - Y1);

slope = (SlopY) / (SlopX);

if(SlopX == 0){

cout "Line is parallel to Y-Axis" endl;
}

else {

if(SlopY == 0){
cout "Line is parallel to X-Axis" endl;
}

else {
if(slope == 1){
cout "Line will make the 45 degree angle with the horizon" endl;
}

else{

if(slope < 1){
cout "Line will travel more along X-Axis and Less along Y-Axis" endl;
}

else {

if(slope > 1){
cout "Line will travel more along Y-Axis and Less along X-Axis" endl;
}
}
}

}

}
system("pause");
return false;
}

Views: 3229

### Replies to This Discussion

#include<iostream.h>
using namespace std;

main()

{
int x1, x2, y1, y2;
float sx, sy, s;
cout"X-Coordinate of the start point= ";
cin>>x1;
cout"Y-Coordinate of the start point= ";
cin>>y1;
cout"X-Coordinate of the ending point= ";
cin>>x2;
cout"Y-Coordinate of the ending point= "
cin>>y2;
coutendl;
sx=(x2-x1);
sy=(y2-y1);
s=sy/sx;

if(sx==0)

{
cout "Line is Parallel to Y"endl;
}
else
{
if (sy==0)
{cout"Line is Parallel to X"endl;
}
else
{
if(s==1)
{cout"45 degree angle with the horizon"endl;
}
else
{ if(s<1)
{cout"more along X-Axis and less along Y-Axis"endl;
}
else
{ if(s>1)
{cout"more along Y-Axis and less along X-Axis"endl;
}
}
}
}
}
coutendl;
system("PAUSE");
}

#include <iostream>
#include <stdlib.h>
int main()

{
using namespace std;

int X1, X2;
int Y1, Y2;

float slope, SlopX, SlopY;

cout "Enter The X-Coordinate of the starting point = ";
cin >> X1;

cout "Enter The Y-Coordinate of the starting point = ";
cin >> Y1;

cout "Enter the X-Coordinate of the Ending point = ";
cin >> X2;

cout "Enter the Y-Coordinate of the Ending point = ";
cin >> Y2;

SlopX = (X2 - X1);

SlopY = (Y2 - Y1);

slope = (SlopY) / (SlopX);

if(SlopX == 0){

cout "Line is parallel to Y-Axis" endl;
}

else {

if(SlopY == 0){
cout "Line is parallel to X-Axis" endl;
}

else {
if(slope == 1){
cout "Line will make the 45 degree angle with the horizon" endl;
}

else{

if(slope < 1){
cout "Line will travel more along X-Axis and Less along Y-Axis" endl;
}

else {

if(slope > 1){
cout "Line will travel more along Y-Axis and Less along X-Axis" endl;
}
}
}

}

}
system("pause");
return false;
}
right or wrong

koi b solution correct nai hay sab me errors hn.... need correct solution

Ayesha is r8.......... every file has some errors which is not compiling the code.........

Complete solution

Plz Compile and Run

Attachments:

Yes. It is r8 code. Thank u so much Subhan.................................... God Bless U.

Fazli subhan thanks for sharing

1

2

3

4

5

## Latest Activity

Huma noor left a comment for Karina Lopez
1 hour ago
Shoaib Hasan Khan updated their profile
2 hours ago
memon added a discussion to the group CS615 Software Project Management

### cs615 midterm paper fall 2021

4 hours ago
4 hours ago
alvia khan posted a discussion

12 hours ago

### ENG502 Current Midterm Paper 20/1/2022 5:30pm

15 hours ago
pcscrack posted a blog post

### EaseUS Partition Master License Code

17 hours ago
Nida Arshad Javaid Ch posted a video

17 hours ago