Sponsored Links


Results 1 to 2 of 2

Thread: CS201 Introduction to Programming Assignment No.1 Solution Spring Semester 2013

  1. #1
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    8,835

    18 CS201 Introduction to Programming Assignment No.1 Solution Spring Semester 2013

    Sponsored Links





    CS201 Introduction to Programming Assignment No.1 Solution Spring Semester 2013


    I have write some code this is not full code i am try to make i think there is if else statement need

    #include <iostream>
    #include <stdlib.h>
    #include <math.h>
    // Main Function
    int main(){
    using namespace std;

    int p1,p2;

    Sponsored Links

    int y1,y2;

    int x1, x2;

    float resultSlope;
    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;
    resultSlope = (y2 - y1) / (x2 - x1);
    }

  2. Sponsored Links
  3. #2
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    8,835
    Idea Solution :


    #include <iostream.h>

    main()

    {
    // Declaring variables for input (x,y) and (x1,y1)
    int a,b,c,d;
    // Declaring variables for formula dx(x1 - x) and dy(y1 - y)
    float m,x,y;

    cout "Enter the X - Coordinate of the Starting point = ";
    cin>> a;

    cout "Enter the Y - Coordinate of the Starting point = ";

    cin>> b;

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

    cin>> c;

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

    cin>> d ;
    // acording to formula dx(x1 - x)
    x = c-a ;
    // show message if the resualt (x1 - x)= 0
    if (x==0)
    { cout "Line is parallel to Y - Axis ";
    }
    else
    {
    // show message if the resualt (y1 - y)= 0
    y = d-b ;
    if (y==0)
    { cout "Line is parallel to X - Axis ";
    }
    else
    {
    // show message if the resualt (dy/dx )= 1
    m = y/x;
    if (m==1)
    {
    cout "Line will make the 45 degree angle with the Horizon ";
    }
    else
    {
    // show message if the resualt dy/dx > 1
    if (m>1)
    {
    cout "Line will travel more along Y- Axis And less along X- Axis" ;
    }
    // show message if the resualt dy/dx < 1
    if (m<1)
    {
    cout "Line will travel more along X- Axis And less along Y- Axis" ;
    }
    }
    }
    }
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. CS201-Introduction to Programming Assignment No.2 Spring semester 2014
    By vuassignments in forum Assignments & Solutions
    Replies: 0
    Last Post: 07-09-2014, 04:14 PM
  2. Replies: 0
    Last Post: 07-13-2013, 07:07 PM
  3. Replies: 1
    Last Post: 06-24-2013, 10:39 PM
  4. Replies: 5
    Last Post: 05-17-2013, 02:55 AM
  5. Replies: 2
    Last Post: 11-20-2010, 09:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft