Could sum1 plz help me undastand these Questions
just wna no how it is done

fank u

  1. If DoSomething is a void function that takes an int expression as an argument, which of the following is an incorrect statement? (Assume all variables are int variables.)

    A) DoSomething(n);
    B) DoSomething(3*n + 24);
    C) length = DoSomething(width);
    D) b and c above
    E) a, b, and c above

  2. Given that x is a float variable and num is an int variable containing the value 38, what will x contain after execution of the following statement:

    x = num / 4 + 3.0; 
    

    A) 12.5
    B) 13
    C) 12
    D) 12.0
    E) nothing; a compile-time error occurs

    1. Given the constant declaration

      const int FACTOR = 95;

      which of the following is not a valid use of FACTOR?

    A) cout << FACTOR * 3;
    B) FACTOR = 24;
    C) cin >> FACTOR;
    D) a and c above
    E) b and c above

  3. Assuming alpha and beta are int variables, what is the output of the following code (which is indented poorly)?

    alpha = 3;
    beta = 2;
      if (alpha < 2)
      if (beta == 3)
    cout << "Hello";
    else cout << "There"; 
    

    A) Nothing is output.
    B) Hello
    C) There
    D) HelloThere

  4. The function heading

      float TenToThePower( /* in */ int n )
    
    is for a function that returns 10.0 raised to any integer power. Which of the following statements represents an appropriate use of the TenToThePower function? 
    

    A) someFloat = 4.96 * TenToThePower(8) + 2.5;
    B) TenToThePower(6);
    C) if (TenToThePower(someInt) > someFloat)
    beta = 3;
    D) a and b above
    E) a and c above

  5. Given the function definition

      int Mystery( /* in */ float someVal )
      {
          if (someVal > 2.0)
              return 3 * int(someVal);
          else
              return 0;
      }
    
        what is the value of the expression  Mystery(4.2)  ? 
    

    A) 12
    B) 12.0
    C) 0
    D) 0.0
    E) nothing--the function call is invalid

    1. Which of the following is a valid use of the C++ cast operation?

    A) gamma = short(delta);
    B) beta = (long double) alpha;
    C) beta = long double(alpha);
    D) a and b above
    E) a, b, and c above

  6. Given the declarations

    enum MovieRatings {G, PG, PG13, R, X};
    MovieRatings thisOne;
    
    and assuming that thisOne currently contains a value less than X, which of the following statements can be used to "increment" thisOne? 
    

    A) thisOne = thisOne + 1;
    B) thisOne++;
    C) MovieRatings(thisOne++);
    D) thisOne = MovieRatings(thisOne + 1);
    E) thisOne = MovieRatings(thisOne) + 1;

  7. Given the declarations

      struct RecType1
      {
          int   length;
          float width;
      };
      struct RecType2
      {
          int   length;
          float width;
      };
      RecType1 myRec;
      RecType2 yourRec;
    
      which of the following assignment statements is valid? 
    

    A) myRec.length = yourRec.length;
    B) myRec = yourRec;
    C) myRec.length = yourRec;
    D) a and b above
    E) none of the above

    1. Assume that myclass.h and myclass.cpp are files for a class MyClass and that someprog.cpp is a client of class MyClass. Which file(s) must #include the file myclass.h?

    A) someprog.cpp
    B) myclass.cpp
    C) myclass.h
    D) a and b above
    E) a, b, and c above

    1. Consider the class declaration

      class SomeClass
      {
      public:
      void Func();
      private:
      int m;
      int n;
      };

      and client code
      

      SomeClass alpha;
      SomeClass beta;
      ...

      Considering both pieces of code above, which identifiers are names of class objects?

    A) m and n
    B) alpha and beta
    C) SomeClass, m, and n
    D) alpha, beta, m, and n
    E) Func, m, and n

    1. After execution of the code fragment

      int arr[5];
      int i;

      for (i = 0; i < 5; i++)
      {
      arr[i] = i + 2;
      if (i >= 3)
      arr[i-1] = arr[i] + 3;
      }

      what is contained in arr[1]?
      A) 2
      B) 3
      C) 7
      D) 8
      E) none of the above

    2. What does the following C++ statement do?

      ptr = new RecType;

    A) It allocates a dynamic variable named ptr.
    B) It allocates a dynamic variable and stores the address into ptr.
    C) It deallocates the variable ptr.
    D) It deallocates the dynamic variable that is pointed to by ptr.

    1. Given the declaration

      int* somePtr;

      which of the following is a valid statement?

    A) somePtr = new int*;
    B) delete somePtr;
    C) delete *somePtr;
    D) a and c above
    E) a, b, and c above

    1. Given the declarations

      struct ListNode
      {
          float     volume;
          ListNode* link;
      };
      ListNode* ptr;
      
      what is the data type of the expression ptr.volume ? 
      

    A) ListNode*
    B) ListNode
    C) float
    D) *ListNode
    E) none--the expression is invalid

What is there you cannot understand? If you expect someone to hand out the answers then you are wrong.

sum1 plz
wna no
fank u

Use real words...

no i no what the answers are dont worry,lol

just wanted to no how it is
like Q3 i no the answer is C and stuff just wanted to no how it is

You should stop talking like a kid. 'No' and 'know' are two different words. You could also use some CAPS. Read the rules (the part called 'keep it clean')

But on topic: how do you know that the answer is 'c' if you don't know why?
If the teacher gave you the answers you could ask him for help right?

i probably am a kid thats why im talking the way it is

and yeah we got the answers along with the questions, just wanted to know how it is that it works out to be that, could put up the answer if it helps

Lets take Q3, you have to know that void means that the function does not return any value. That means that option C is incorrect and A is perfectly valid. Option B is where one might get stuck, but since 3*n + 24 amounts to an int, option B is also valid. That means that only option C is incorrect and hence C is the answer.

Why dont you give a shot at all the questions in similar manner and post here why you think a option is the answer. We will correct you if you are wrong.

Thanks

4. Given that x is a float variable and num is an int variable containing the value 38, what will x contain after execution of the following statement:

x = num / 4 + 3.0;

A) 12.5
B) 13
C) 12
D) 12.0
E) nothing; a compile-time error occurs


With Q4 the answer is D 12.0 but if u work it out you get 12.5 ??


Q10 ive worked out now

Q14:
Assuming alpha and beta are int variables, what is the output of the following code (which is indented poorly)?

alpha = 3;
beta = 2;
if (alpha < 2)
if (beta == 3)
cout << "Hello";
else cout << "There";

A) Nothing is output.
B) Hello
C) There
D) HelloThere


the answer is A)
but i thought it would b C)there as it fails on both the if's and it said

else cout>>"there"

> With Q4 the answer is D 12.0 but if u work it out you get 12.5 ??
Think about the difference between integer division, and float division.
Which applies in this case?

> else cout>>"there"
Consider which of the 'if' statements this else statement binds to?

integer division

and the else statement is binded to the second IF statement ?

but say right that the first IF statement was to work and the second didnt what would have been the outcome then ?

Question 27 is something which i havnt understood at all

27. The function heading

float TenToThePower( /* in */ int n )

is for a function that returns 10.0 raised to any integer power. Which of the following statements represents an appropriate use of the TenToThePower function?

A) someFloat = 4.96 * TenToThePower(8) + 2.5;
B) TenToThePower(6);
C) if (TenToThePower(someInt) > someFloat)
beta = 3;
D) a and b above
E) a and c above

For Q14

The else is binded to the second if statement, but note that the second if itself will be executed only if the first 'if' holds true. Its like saying
if(condition)
{
if(condition)
{
}
else
{
}

}

For 27, solve it like Q3, the answer should come out as E. You have to know how function returning values work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.