hi all

i have a C++ assinment and i can't solve it can anyone help me to solve it is three questions:

Q1. Write a C++ program that sends a pointer of an array of characters to function with the function profile void Analyze ( char *abc) . Function Analyze will print number of characters , number of spaces , number of words, number of lower case and number of upper case characters in the array.
you have to use arrays and pointers only; it is not allowed to use any string nor string functions.

Hint: use ASCII table.

Sample output:
For the following string:
" I am a C++ programmer"

The number of characters is: 17.
The number of spaces is: 4.
The number of words is: 5.
The number of upper case characters is: 2.
The number of lower case characters is: 13.

----------------------------------------------------------------------------


Q2. Implement a class RectangularCuboid which has width, length and depth. The initial values of the data members should be 1 . (the data members cannot be set to 10)

your class should contain a function setDimensions that should take the depth, length and hieght from the caller , check if the calues are valid and store them . You should implement a function named calculate that should return the area , volume and circumference together ( use an appropriate method to return all of them in one call)


----------------------------------------------------------------------

Q3. Write a function that can solve two linear equations with two unknowns. The solution should be returned through pointers or reference parameter. The main program should read the six coefficients, call the function, and display the solution.

a . x + b . y = c

d . x + e . y = f

----------------------------------------------------------------------

these all the question hope that u will help me to solve them because i tried but am too weak in programming please help me ...

i didn't know how 2 solve the first one i don't know what is the ASCII table or how to use it ..


the last one i tried but i don't know if it the right way or not and i didn't complete it ...
this for question 3

#include <iostream>
#include <iomanip>
using namespace std;
 
// Define a function
void solveit ( int , int , int , int , int , int , double *, double * );
 
 
int main()
{
	int a; 
	int b; 
	int c; 
	int d; 
	int e; 
	int f; 
	double x, y;
 
	cout << "Please enter three coefficients of the 1st linear equation,\nin the form Ax + By + C = 0\n";
	cin >> a >> b >> c;
 
	cout << "\nPlease enter three coefficients of the 2st linear equation,\nin the form Dx + Ey + F = 0\n";
	cin >> d >> e >> f;
 
	cout << endl;
	cout << "\nThe 1st linear equation is: " << a << "x + " << b << "y + " << c << endl;
	cout << "The 2nd linear equation is: " << d << "x + " << e << "y + " << f << endl;
 
	solveit( a, b, c, d, e, f, &x, &y );

	cout << "\nx = " << x << " ,and, y = " << y << endl;
 
	return 0; // indicates successfully termination
 
 
}

void solveit( int aPtr, int bPtr, int cPtr, int dPtr, int ePtr, int fPtr, double *xPtr, double *yPtr )
{

that's all what i write 4 now !!

Here's a leg up...

Technically

char ary[] = "Never go down to the whithering woods. The creatures who live there are up to no good. The gnomes are nasty and the trolls are hairy, and the creatures who live there are scary";

That is not a string. That is a character array!

char *p = ary;
char *p = &ary[4];

problem #2

class RectangularCuboid
{
private:
      float width;
     float height;
     float depth;
public:
RectangularCuboid();
~RectangularCuboid();
void setDimensions( float w, float h, float d );
}

problem #3
use a class or struct

class vec2D
{
   float x;
   float y;
};

#3 I used a structure because the posted problem appeared to be a structure reference:
Original:

a . x + b . y = c
d . x + e . y = f

With whitespace taken out

a.x + b.y = c
d.x + e.y = f

But it could have been done as scalars

ax + by = c
dx + ey = f

But since problem #2 was a class, it made sense for #3 to be one as well! But then again, I'm only guessing based upon the clarity of the original postings.

@wildgoose :What you mentioned was one of the better ways to do the problem. I told the OP that it can be done even without that too just after sensing his difficulty in understanding basic concepts.And I didn't want to make his implementation more problematic(for him of course) by including another C concept(structures) here. :)

thanks csurfer. Just trying to help others while at the same time dusting off my ability to look at others code and help debug it.

This article has been dead for over six months. Start a new discussion instead.