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

No Comments

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

{
       using namespace std;
      /*

      Please pray for me....
      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
      facebook.com/ali.mirchal

      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;
  }
Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment