I am doing private studies on c++ and have no tutors. Can someone help me with the following. I will write exams end of the year in c++
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 you would use (or call) your fucntion by writting a code to cpy one string into another
2 1849
please use code tag to list the coding. -
void calculatevalues (const int &a, float *b, int &c)
-
{
-
float d = 20.4;
-
-
if (*a =0) {
-
-
*a += 1;
-
c = a + d;
-
} else {
-
-
b = c/d ;
-
c = a - b + d;
-
}
-
the errors mostly were syntaxz error?
the calculation you fix it yourself or some other ppl would help you by then.
all the best.
please use code tag to list the coding. -
void calculatevalues (const int &a, float *b, int &c)
-
{
-
float d = 20.4;
-
-
if (*a =0) {
-
-
*a += 1;
-
c = a + d;
-
} else {
-
-
b = c/d ;
-
c = a - b + d;
-
}
-
the errors mostly were syntaxz error?
the calculation you fix it yourself or some other ppl would help you by then.
all the best.
thank you very much it worked out
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Massimo |
last post by:
I'm planning to develop a .NET application using C#, in order to sell it as
a shareware and/or as a full package, so I'll need a good way to protect it
against piracy. I know some ways to protect it (activation, serial keys,
etc.), but my concern is: how can any copy protection mechanism work when
you can always disassemble it and read the source code? Even if I use a
native C++ DLL for my copy protection, the point where it's called from...
|
by: Matt Garman |
last post by:
What is the "best" way to copy a vector of strings to an array of
character strings? By "best", I mean most elegantly/tersely written,
but without any sacrifice in performance.
I'm writing an application using C++ and the STL for handling my data.
Unfortunately, I must interact with a (vanilla) C API. I use vectors of
strings (for simplicity and less memory hassle), but the function calls
for this API require arrays of character...
|
by: stroker_ace |
last post by:
Hi,
I am working on a problem where I need to implement a string buffer
that I can remove an arbitary length char* from one end and add them to
the other.
So far the only way I have thought of to accomplish this task involves
creating using
new char;
|
by: Lafer |
last post by:
Hello,
I am attempting to write a terminal interface program using PowerPC
Assembly/C, where I am using an integer-to-ASCII conversion algorithm.
Unfortunately, I have run into some difficulties that seem to deal
with the syntax/character types that am I using. Below is a segment of
my code which is intended to convert an integer to an array of ASCII
digits:
> > char * inttoascii(int val)
|
by: Simon Schaap |
last post by:
Hello,
I have encountered a strange problem and I hope you can help me to
understand it. What I want to do is to pass an array of chars to a
function that will split it up (on every location where a * occurs in
the string). This split function should allocate a 2D array of chars
and put the split results in different rows. The listing below shows
how I started to work on this. To keep the program simple and help
focus the program the...
| |
by: swarsa |
last post by:
Hi All,
I realize this is not a Palm OS development forum, however, even though
my question is about a Palm C program I'm writing, I believe the topics
are relevant here. This is because I believe the problem centers
around my handling of strings, arrays, pointers and dynamic memory
allocation. Here is the problem I'm trying to solve:
I want to fill a list box with a list of Project Names from a database
(in Palm this is more...
|
by: Fred |
last post by:
Hi:
I've got the following request: (suppose the required head file
is included)
vector<stringvec;
// ..........
// push some items into vec
string str; // here I want to
copy some range of elements from vec to str, for example, from vec
|
by: Jeffrey Barish |
last post by:
(Pdb) myclass
MyClass( 0, 0, 'A string', 123.45)
(Pdb) copy.copy(myclass)
*** TypeError: TypeError('__new__() takes at least 4 arguments (2 given)',)
I see 4 arguments (actually, 5 because Python is passing cls invisibly to
__new__). Does anyone have an idea what is going on here?
I have not defined __new__ in MyClass above. I can make the problem go away
on one platform by defining __new__ as
|
by: Jason |
last post by:
I want to create a simple program with Two buttons on the form.
BUTTON 1 - BACKUP PREFS
this will do the following:
Copy C:\Documents and Settings\%USERNAME%\Application Data\FileZilla
\sitemanager.xml
to this location: \\drake\pvt\%USERNAME%\FileZilla-Prefs\
BUTTON 2 - RESTORE PREFS
this will do the opposite:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |