473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

c++ help answers

Could you please help with answers to the below questions. I am still learning c++ and would appreciate your help

1. what is the difference between
int value =2; int value =2;
cout << ++ value <<endl; AND cout << value++ << endl;?


2. What are magic numbers? Whay are they considered bad practise. How does c++ language encourage the programmer to avoid using magic numbers?

3 Intergers are represented as sequence of bits. what is the correct order ( from largest to smallest) of relative sizes in bits of the interger typers


a long >= char >=short >=int
b long>= int >=short>=char
c long >=int >=char>=short
d long >=char >=int >=short

4. how can one write a c++ programme which does the following

a create a vector of size 1000 and have it store the values 0.1, 1.1, 2.1, 3.1,....999.1

b trucate the vector to a size of 5

c print out how many values the vector is storing

d empty out the vector so that it stores no values


5. rewrite the following code correcting all problems found

void calculatevalues (const int &a, float *b, int &c)

{
d = 20.4;

if (*a =0)

*a += 1
c = a +d;

else

b= c/d ;

c= a- b +d;

}

Hint if a =4, b =0.0 and c=5 when this function is called, their values when this fucntion returns should be a=4, b=0.25 and c= 24.15

6 a The string class in the standard c++ library is a template for any type character of character representation.

write a function called copy which takes two parameters of the string type. The first parameter is the source string ( or the string to be copied) and the second parameter is the target string ( or the string that recieves the copy). This function need not return anything.

One is not allowed to use the fuction strcpy (.....)!

b) show how one would use (or call) your function by writting some c++ code to copy one string inro another.

7 What are the guidelines or rules for c++ programmers using inline functions?
Feb 7 '07 #1
7 1896
willakawill
1,646 1GB
Hi. Are you ready for valuable expert assitance?
Here it is; go to your teacher and work through these questions. If this is a test and you have to do this alone then you are too late. TheScripts is not a place to get your tests completed for you.
Feb 7 '07 #2
Hi. Are you ready for valuable expert assitance?
Here it is; go to your teacher and work through these questions. If this is a test and you have to do this alone then you are too late. TheScripts is not a place to get your tests completed for you.
SORRY I AM STUDYING C++ ON MY OWN AND THESE ARE SOME OF THE PRACTICAL QUESTIONS AT THE END OF THE MODULE. THE EXAM WILL BE THERE IN DECEMBER. I HAVE TO PRACTISE AS I PROCEED WITH THE STUDIES
Feb 7 '07 #3
nickyeng
254 100+
for your question number 1:
Expand|Select|Wrap|Line Numbers
  1. int value = 2;
  2.  
  3. cout << ++value << endl;
  4.  
will output the value as 3.

Expand|Select|Wrap|Line Numbers
  1. int value = 2;
  2.  
  3. cout << value++ << endl;
  4.  
would output the value as 2. after output, the value become 3.

do you get what i mean?
correct me if i'm wrong. cos i'm new to c++ too.
haha..

I noticed that you have many question that are un-answer. Why dont you give a search on google and then if still no find any, ask the seniors here.
Go through your module notes, and then see if these question's answer you might find it on module notes.

from Nicky Eng
Feb 7 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
The experts on this site are more than happy to help you with your problems but they cannot do your assignment for you. Attempt the assignment yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

So break the assignment down into sections. Attempt it yourself first. Then ask questions. Make sure you state that you are doing distance learning and don't have access to a tutor to ask questions of. The experts will help you they just won't do your assignment for you.

Mary
Feb 8 '07 #5
The experts on this site are more than happy to help you with your problems but they cannot do your assignment for you. Attempt the assignment yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

So break the assignment down into sections. Attempt it yourself first. Then ask questions. Make sure you state that you are doing distance learning and don't have access to a tutor to ask questions of. The experts will help you they just won't do your assignment for you.

Mary
Thanks for the advice maybe lets only do the following

5. rewrite the following code correcting all problems found

void calculatevalues (const int &a, float *b, int &c)

{
d = 20.4;

if (*a =0)

*a += 1
c = a +d;

else

b= c/d ;

c= a- b +d;

}

Hint if a =4, b =0.0 and c=5 when this function is called, their values when this fucntion returns should be a=4, b=0.25 and c= 24.15

6 a The string class in the standard c++ library is a template for any type character of character representation.

write a function called copy which takes two parameters of the string type. The first parameter is the source string ( or the string to be copied) and the second parameter is the target string ( or the string that recieves the copy). This function need not return anything.

One is not allowed to use the fuction strcpy (.....)!

b) show how one would use (or call) your function by writting some c++ code to copy one string inro another
Feb 8 '07 #6
for your question number 1:
Expand|Select|Wrap|Line Numbers
  1. int value = 2;
  2.  
  3. cout << ++value << endl;
  4.  
will output the value as 3.

Expand|Select|Wrap|Line Numbers
  1. int value = 2;
  2.  
  3. cout << value++ << endl;
  4.  
would output the value as 2. after output, the value become 3.

do you get what i mean?
correct me if i'm wrong. cos i'm new to c++ too.
haha..

I noticed that you have many question that are un-answer. Why dont you give a search on google and then if still no find any, ask the seniors here.
Go through your module notes, and then see if these question's answer you might find it on module notes.

from Nicky Eng
Thanks a lot for your advice may be lets only do the following


5. rewrite the following code correcting all problems found

void calculatevalues (const int &a, float *b, int &c)

{
d = 20.4;

if (*a =0)

*a += 1
c = a +d;

else

b= c/d ;

c= a- b +d;

}

Hint if a =4, b =0.0 and c=5 when this function is called, their values when this fucntion returns should be a=4, b=0.25 and c= 24.15

6 a The string class in the standard c++ library is a template for any type character of character representation.

write a function called copy which takes two parameters of the string type. The first parameter is the source string ( or the string to be copied) and the second parameter is the target string ( or the string that recieves the copy). This function need not return anything.

One is not allowed to use the fuction strcpy (.....)!

b) show how one would use (or call) your function by writting some c++ code to copy one string inro another
Feb 8 '07 #7
The experts on this site are more than happy to help you with your problems but they cannot do your assignment for you. Attempt the assignment yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

So break the assignment down into sections. Attempt it yourself first. Then ask questions. Make sure you state that you are doing distance learning and don't have access to a tutor to ask questions of. The experts will help you they just won't do your assignment for you.

Mary
May i post the answers that i had attempted for the questions and maybe you could help me to check if they are correct
Feb 8 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Andrew Poulos | last post by:
I've built a javascript driven quiz. Given that client-side scripting is not secure, is there a way to "obscure" answers so that they are unavailable to the casual viewer? For example, If I have an...
0
by: softwareengineer2006 | last post by:
All Interview Questions And Answers 10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP) I have listed over 10000 interview questions asked in interview/placement test papers for...
5
by: Sukh | last post by:
I have to design a "Online Test Application" and application is going to display question and answers.All the questons are objective type so there is four answer for each question. My Question is...
0
by: debjanib | last post by:
I am trying to show a FAQ questionnaire set , with set of questions and then with the answers. At First there will be a list of questions and then then will be a list of questions and answers. ...
4
by: Pyenos | last post by:
#!/usr/bin/python #################################################### # answers.py --- A simple answer bot # Copyright (C) 2006 Logan Lee # # MESSAGE: # # This program is a simple...
1
by: javedna | last post by:
Can PHP help with the following as I have tried in the MYSQL Forums and cant get any help Thanks Nabz ---------------------------------------- Hi I am developing a PHP MYSQL questionnaire...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.