Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

The Body Mass Index Program and Matric Certificate Program, Compulsory assignments

Rating
-
Sold
-
Pages
11
Uploaded on
09-11-2022
Written in
2022/2023

Assignments 2 and 3 in Mat1503 deal with vectors and determinants ,particularly helpful for engineering and computer science students who will apply these principles in real life through the design of efficient search engine algorithms (matrices and determinants ) and safer vehicles (vectors) The assignments 2 and 3 in COS1511 deal with solving common problems and automating simple tasks such as calculating your BMI (Body Mass Index) and automating a Matric Certificate program in a more interactive manner.

Show more Read less
Institution
Course

Content preview

Shivam_12596388_Assignment 2_uniqueCode_830369



Question 1 COS1511 Assignment 2: Writing Function headers in C++

Part (i): The function that returns no value from the caller
void check(int param1,float param2)
{
param1>param2;
param2=param1;
param2<param1;

}




Part (ii): The function that multiplies two values and returns the result:
void mult(float var1,float var2)
{
cout<<var1*var2;
}
int main()
{
mult(2,3);

return 0;

}




Part (iii): The function that tells you how many seconds, minutes and hours are in a day
void time(int seconds, int minutes,int hours)
{
cout<<"Within a day there are
"<<seconds<<"seconds,”<<minutes<<”minutes”<<hours<<”hours in a day
“<<endl<<endl;
}
int main()
{
time (60,60,24,);
return 0;
}

, Shivam_12596388_Assignment 2_uniqueCode_830369



Part (iv): The function that counts the amount of characters in a given string (phrase or sentence)

void countChar (string phraseofCharacters,int TotalCharacters)
{

phraseofCharacters="MonkeyBanana";

TotalCharacters=12;

cout<<"The phrase "<<phraseofCharacters<< " has "
<<TotalCharacters<< "Characters in the phrase
"<<phraseofCharacters<<endl<<endl<<endl;

}
int main ()
{
countChar( "MonkeyBanana",12 );

return 0;
}




Question 2 COS1511 Assignment 2: Debugging Errors in functions

Correcting errors in output code 2i

To call a function, simply do the following;
int main()
{
function1();

return 0;
}

Do not do the following in terms of calling functions

a) endl; int function2()

b) cout << "Inside function function1 " << endl;

Do the following to correct the above errors when calling functions in C++

• Always include the function you created within the main function within the default int
main () function.

• Never include endl;when ending functions , simply use the {} to end functions

• You cannot call a function without stating it in int main()

Written for

Institution
Course

Document information

Uploaded on
November 9, 2022
Number of pages
11
Written in
2022/2023
Type
OTHER
Person
Unknown

Subjects

$12.19
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
shivamnaik
5.0
(1)

Also available in package deal

Get to know the seller

Seller avatar
shivamnaik University of South Africa (Unisa)
Follow You need to be logged in order to follow users or courses
Sold
6
Member since
3 year
Number of followers
2
Documents
15
Last sold
10 months ago
The Innovaters Academy, Where winning never ends

We cater for all your academic needs from study guides to exam past papers pertaining to the school of computing at the University of South Africa Moreover we also provide the best advice to all future Bill Gates , Elon Musks and Jeff Bezos`es out there For more information on all your academic needs ,please contact the following number; 071 116 2030 Mr SS Naik

5.0

1 reviews

5
1
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions