Thread: Help on this pls

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    4

    Help on this pls

    These are not homework but some short problem question in my pdf notes with no answer. i am having a short quize/test soon and my teacher is away so i can only get help online. So anyone kind enough to help me on the solution. it should be easy because its not like i want the entire programming done. But its a bit of questions involve.

    Heres the pdf notes i am using. Please d/l it here:

    http://www.yousendit.com/transfer.ph...3BD3D745F29032

    Answers that i need are:
    Go to: pg179,B 1to4
    pg180,C1to3
    pg182, B3,B4....Section C, C1,C2
    pg184,B1a)b)c)d) and B2...Section C ,C1
    pg188,B1,C1,C2
    pg190,B1,B2,B3
    pg191,C1a)b)
    -----------------------------------------------------------------------
    Thats about it. Big thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    How about you copy/paste the actual questions which are causing you some difficulty rather than us having to d/l a 200 page (SPRG%20ver2_4.pdf (3343 KB)) document just to look at 5 questions.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    4
    its not 5 questions but a few sub ones but i post anyway. i know some of the answer but just wated to confirm my answers.

    B3. Why is it easier to program in high-level languages than in machine
    language or assembly language?
    B4. Where are programs stored in a computer system?
    C1. What are the errors (if any) in the following lines of C++ code:
    Code:
    main()
    int step, start, stop = 100;
    step = 5; start = 10.5;
    C2. Can a compiler tell if a program will do exactly what is expected of it?
    (i.e. can it find logical programming errors?) Give reasons for your
    answer.
    C3. What are the errors (if any) in the following lines of C++ code:
    Code:
    int my pay; 
    Double salary; 
    int num1; num2; 
    char 2answers;
    B3. How much memory (in bytes) is occupied by each of the following
    variables?
    double number; int count, index; char yesno;
    B4. What is the output of the following code segment?
    Code:
    int num = 100;
    cout << “Decimal : “ << dec << num << “\n”; cout << “Octal : “ 
         << oct << num << “\n”; cout << “Hexa : “ 
         << hex << num << “\n”;
    Section C: C++ language Syntax & Debugging
    C1. Why are include files like <iostream> needed?
    C2. Spot and correct the errors in the following code:
    Code:
    #include <iostream> 
    using namespace std; 
    #include <iomanip> #define PI=3.14 
    Main() 
    { 
    int count; double colorVal
    cout << “Enter an integer number ; 
    cin >> “count” ; 
    colorVal = PI*count; 
    cout << "\nThe color value is : " << setw(8) 
         << fix << setprecision(2) << colorVal;
    }
    B1. Evaluate the following expressions:
    (a) 21 % 4 % 2 * 3 + 2
    (b) 25 % 3 + 2
    (c) 18 + (5==5) * 10 % 4
    (d) 5/2 + (85 >= 86)
    B2. Study the following code and write the output.
    Code:
    main() 
    {
     int x, y, z=4;
    y = (7+6) % 5 / 2; cout << y << “\n” ; 
    z *= 3 + 2; cout << z << “\n” ; 
    x=y==z; cout << x << “\n” ; 
    }
    Section C: C++ language Syntax & Debugging
    C1. Will the compiler give any error for the following code?
    Code:
    double temp;
    cout << “Enter a floating point number :”;
    cin << temp;
    B1. Consider the code given below:
    Code:
    int direction; 
    if (direction == 1) 
    cout << “Robot moving left\n”; 
    else if (direction == 2) 
    cout << “Robot moving right\n”; 
    else if (direction == 3) 
    cout << “Robot moving up\n”; 
    else if (direction == 4) 
    cout << “Robot moving down\n”; 
    else 
    cout << “Robot standing still\n”;
    Re-write the above code using a switch statement.

    Section C: C++ language Syntax & Debugging
    C1. What is wrong (if anything) with the following code?
    Code:
    x=80; 
    if (x = 100) cout << "Excellent" ;
    C2. Determine the errors in the following program.
    Code:
    main() 
    { 
    int a=5, b=10; char operation; 
    cout<<“Enter the operation [+, -, * or /]:); 
    cin >> operation ; 
    switch (operation) 
    case ‘+’ : c = a+b; 
    case ‘-’ : c = a-b; 
    case ‘*’ : c = a*b; 
    case ‘/’ : c = a/b; 
    }; 
    cout << a << operation << b <<”=”<< c; 
    }
    Section B: Programming Concepts
    B1. What will be the output of the following code:
    Code:
    int i; 
    for(i=10; i<20; i=i+2) 
    { 
    cout << i*10 ; 
    }
    B2. Rewrite the code in B1 using a while loop

    B3. What is the output of the following code?
    Code:
    int count = 1, odd = 0; 
    do 
    { 
    if ( (count % 2) != 0 ) 
    odd++; 
    count++; 
    }while (count<10); 
    cout << “odd = “ << odd;
    Section C: C++ language Syntax & Debugging
    C1. Spot and correct the errors in the following code segments:
    (a)
    Code:
    int num; 
    for(num=1, num<=10, num=num+1) 
    { 
    cout << “The square of num is : << num*num ; 
    }
    (b)
    Code:
    char input; 
    double voltage current;
    while (input = y); 
    { 
    cout << “Enter the voltage and current : “; 
    cin >> voltage >> current; 
    cout << “The resistance is ” << voltage/current; 
    cout << Do you wish to continue [y/n] : “; 
    input << cin ; 
    }

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > i know some of the answer but just wated to confirm my answers.
    OK, so what are your answer(s) so far, then we can tell you whether you got them right or not.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jun 2006
    Posts
    4
    Quote Originally Posted by Salem
    > i know some of the answer but just wated to confirm my answers.
    OK, so what are your answer(s) so far, then we can tell you whether you got them right or not.
    yeah i know a few 2 or 3 question only. just some guess. i am a beginner in C++.
    eg.like C1, start is double(undeclared)

  6. #6
    Registered User
    Join Date
    May 2006
    Posts
    50
    Quote Originally Posted by watsoncode
    yeah i know a few 2 or 3 question only. just some guess. i am a beginner in C++.
    eg.like C1, start is double(undeclared)
    Hint: try running it with your compiler and see what happens. You can answer all of these[except maybe those where you have to rewrite things] if you just put them in a compiler, hit run and see what happens and what errors, if any, you get.

    Trial and error is worth a thousand explanations.

  7. #7
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    >> Trial and error is worth a thousand explanations.

    I like that. In fact, it's going in my signiture. It's just so true.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  8. #8
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Quote Originally Posted by ahluka
    >> Trial and error is worth a thousand explanations.

    I like that. In fact, it's going in my signiture. It's just so true.
    I actually don't agree with it, personally, but if you're compiling someone else's code to see if it works real quick, it's fine.
    Sent from my iPad®

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic port scanner code .. pls help ???
    By intruder in forum C Programming
    Replies: 18
    Last Post: 03-13-2003, 08:47 AM
  2. i dont know what to do. pls. help!!!!
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 03-14-2002, 03:24 PM
  3. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 10:46 AM
  4. pls help me!!
    By hanseler in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2001, 08:46 PM
  5. Pls Help Me In This Question!!!
    By Joanna in forum Windows Programming
    Replies: 1
    Last Post: 10-20-2001, 02:05 PM