could someone please provide me with the answersd to the following c++ problems, they are simple problems which are probably an insult to most of your intelligence but i'm clueless and desperate.
THANKS FOR HELPING:o

1. how would you write this expression in c++? assume all variables are of type double and are named with single letters.

square root of a + 5
cd - |e|

ans=

2. what can be the values of an expression with a relational operator?
ans=

3. The relational operator>=means ans=

4. write a line of c++ code which would assign the value 'true' to boolian variable flag if x is less than or equal to 10.

ans=

5. what is the name of the header file which contains the c++ code for the function getch() ?

ans=

6. findave is a function which calculates the average of x and y and returns the value in ave. Write the function prototype.

ans=

7. write the function for findave described in the previous question.

ans=

8. given the following array named test:

23.0 -2.1 667.4 99.23

write a c++ statement to assign 4.1 to the element indexed by 2

ans=

9. if i is 2, what is stored in test

ans=

10. what is 2 + test[0]?

ans=

11. write c++ code to access the element that contains -2.1

ans=

could someone please provide me with the answersd to the following c++ problems, they are simple problems which are probably an insult to most of your intelligence but i'm clueless and desperate.

More the fact that you obviously missed this post here.. http://www.daniweb.com/techtalkforums/announcement8-2.html

Please friend, it would really be appreciated if you atleast give it a try before completely giving up and waiting for the others to answer your questions. A real programmer has a hell of a fighting spirit so try your level best and then if any problem occurs just let us know.

hello friend, the problem is i have tried to answer the questions and come up with nothing, i'm at desperation stages now and would be really grateful if you could help me out. thanks.

could someone please provide me with the answersd to the following c++ problems, they are simple problems which are probably an insult to most of your intelligence but i'm clueless and desperate.
THANKS FOR HELPING:o

1. how would you write this expression in c++? assume all variables are of type double and are named with single letters.

square root of a + 5
cd - |e|

sqrt (a + 5); // inbuilt C func

2. what can be the values of an expression with a relational operator?
ans = true and false which are boolean types

3. The relational operator>=means

ans= greater than equal to eg. 5 >= 4 is true


4. write a line of c++ code which would assign the value 'true' to boolian variable flag if x is less than or equal to 10.

flag = (x <= 10) ? true : false

5. what is the name of the header file which contains the c++ code for the function getch() ?

#include <stdio.h>


6. findave is a function which calculates the average of x and y and returns the value in ave. Write the function prototype. int findAve (int, int); // assuming input is integer type

7. write the function for findave described in the previous question.

int findAve (int x, int y) 
{
   return ( (x + y) / 2);
}

8. given the following array named test:

23.0 -2.1 667.4 99.23

write a c++ statement to assign 4.1 to the element indexed by 2 test [2] = 4.1; 9. if i is 2, what is stored in test

ans= 99.23

10. what is 2 + test[0]?

ans = 25.0

11. write c++ code to access the element that contains -2.1 float x = test [1]

Hope you will try to understand the way these things have been derived and put some more effort next time.

HOpe it helped, bye.

commented: Don't do people's homework for them. +0

Thank you so much i actually wasn't to far away with some of the answers, you have been brill my friend.

commented: So next time post your attempt and dont be such a sponger! +0

Hope you will try to understand the way these things have been derived and put some more effort next time.

I very much doubt it, you just gave him a free lunch. The real problem with doing other peoples' homework is that they've put no effort into it themselves, so they don't actually learn anything, having not been through the learning processes of thinking about the answers to the questions, or research from textbooks & notes. In the long run, spoonfeeding like that is really a disservice to learners.

A few words to ponder for the OP, intended for Mathematics students originally, but I think it applies to anybody who claims to be in the process of learning something new.

Using a calculator isn't cheating.
Looking up the answers at the back of the book to see how they got there isn't cheating.
Cheating is pretending to understand when you don't.
That is when you are cheating yourself

flag = (x <= 10) ? true : false

You could just write flag = (x <= 10); And you're sorely mistaken if you think your post helped the original poster.

And you're sorely mistaken if you think your post helped the original poster.

This is the first and the last time I am helping him out coz i think everyone in this damned world is entitled to get atleast one chance, from here on he is on his own. Just wanted to give him the push in the required direction so he doesnt give up.

> Thank you so much i actually wasn't to far away with some of the answers,
OK, so next time don't look like a complete and utter leech and actually post what you think the answers are rather than just dump your homework and hope you strike it lucky (and yes, you got lucky this time).

I rather suspect all that's been achieved is deferred failure for you. If you think that was hard, just wait for what's coming.

I agree totally with Bench, this site has a "no homework" policy for a reason, so that spongers like JW1873 don't get a free lunch.

Hi JW1873,
1.The square root is returned using sqrt(); function which is in math.h library.
2.simple - True if the returned value is non-zero and False is the returned value is zero.
3.means greater than or equal to(I describe it this way:if greater than OR if equal to)
4. x >= 10 ? bool_var = 1 : bool_var = 0; // (reference to q. number 2)
5.not needed for today's compilers but it's in stdio.h .
6.

         int findave(int x, int y)
            {  return (x+y)/2;  }

7.refer to 6
8.

 float test[] = { 23.0,-2.1,667.4,99.23 }; // size = 4
 test[2] = 4.1; 

9.

 if( i == 2)
      printf("%d",test[i+1]);

10.simple - nothing.because it has no side effect on your program.
but if it is like this: test[0] = test[0] + 2 then it would get the current value of test[0] and increase it by 2.
11.

int i;
for(i = 0; i <= sizeof(test); i++)
{
     if(test[i] == 2.1)
            printf("element %d contains 2.1",test[i]);
} 

Are these question yours or your exam's questions?
Good luck and don't scare to ask because I'm also a newbie:d.

Excuse me for the double answer.I just wanted to submit this answer yesterday but my internet connection failed to respond.
EXCUSE ME.

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.