Trusted by millions of Kenyans
Study resources on Kenyaplex

Get ready-made curriculum aligned revision materials

Exam papers, notes, holiday assignments and topical questions – all aligned to the Kenyan curriculum.

Write a C++ program that uses new to dynamically allocate a float, a long, and char.Give these dynamic variable values and display their values. Finally, release...

Write a C++ program that uses new to dynamically allocate a float, a long, and char.Give these dynamic variable values and display their values. Finally, release all dynamically allocated memory by using delete.

Answers


Davis
#include
using namespace std;
int main()
{
float *f;
long *l;
char c;
f = new float;
l = new long;
c = new char;
if(!f || !l || !c) {
cout << "Allocation error.*;
return l;
}
*f =10.102;
*l =100000;
* = out << *f << ' ' << *l << ' '<< *c ;
cout << '\n';
delete f; delete l; delete c;
return 0;
Githiari answered the question on May 31, 2018 at 17:22

Answer Attachments

Exams With Marking Schemes

Related Questions