Solved

need help on correcting these codes

Posted on 2004-04-12
14
199 Views
Last Modified: 2010-04-01
Need help in correcting actual codes.  Errors returned from unix.  Please advise.  Del

Code 1:

// ver_7.cpp

#include <iostream>

using namespace std;

int main()
{
   point p_array[2];
   double distance;
   inputFun(p_array);
   distance = calculate_fun(p_array);
   printFun(distance);

   return 0;

}

Code 2:

// ver_8.cpp

#include <iostream>

using namespace std;

int main()
{
   DistanceOfPoints obj_1;
   obj_1.inputFun();
   obj_1.calculateFun();
   obj_1.printFun();

   return 0;
}

Code 3:

// ver_6.cpp

#include <iostream>

using namespace std;

void input_fun(double p_array[2][3]);
double calculate_fun(double p_array[2][3]);
void print_fun(double distance);

int main() {

   double p_array[2][3];
   double distance;

   input_fun(p_array);
   distance = calculate_fun(p_array);
   print_fun(distance);

   return 0;

}

void input_fun(double p_array[2][3]) {

   for(int i = 0; i <= 1; i++)
       for(int j = 0; j <= 2)
            cin >> p_array[i][j];

}

double calculate_fun(double p_array[2][3]) {

   double distance;
     
   distance =

   return distance;

}

void print_fun(double distance) {

   cout << "distance = " << distance << endl;

}

code 4:

// ver5.cpp

#include <iostream>
#include <cmath>

using namespace std;

void input fun(p_array);
double calculate fun(p_array);

int main() {


   double p_array[2][3]; // data structure, memory location for your variable
   double d;

   input fun(p_array);
   calculate fun(p_array);
   print fun(double d);

   d = calculation function;

   print fun(d);

   return 0;

}




0
Comment
Question by:edelossantos
  • 7
  • 5
  • 2
14 Comments
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 10810427
What r the error do u get??

Amit
0
 

Author Comment

by:edelossantos
ID: 10810431
ver5.cc:6: `p_array' was not declared in this scope
ver5.cc:6: variable or field `inputFun' declared void
ver5.cc:7: `p_array' was not declared in this scope
ver5.cc: In function `int main()':
ver5.cc:15: variable or field `inputFun' declared void
ver5.cc:15: initialization to `int' from `double (*)[3]' lacks a cast
ver5.cc:16: initialization to `double' from `double (*)[3]'
ver5.cc:17: parse error before `)'
ver5.cc:19: `calculation' undeclared (first use this function)
ver5.cc:19: (Each undeclared identifier is reported only once
ver5.cc:19: for each function it appears in.)
ver5.cc:19: parse error before `;'
ver5.cc:21: `print' undeclared (first use this function)

ver_6.cpp: In function `void input_fun(double (*)[3])':
ver_6.cpp:27: parse error before `)'
ver_6.cpp:38: parse error before `return'
ver_6.cpp:42: parse error before `{'

ver_7.cpp: In function `int main()':
ver_7.cpp:9: `point' undeclared (first use this function)
ver_7.cpp:9: (Each undeclared identifier is reported only once
ver_7.cpp:9: for each function it appears in.)
ver_7.cpp:9: parse error before `['
ver_7.cpp:11: `p_array' undeclared (first use this function)
ver_7.cpp:11: implicit declaration of function `int inputFun(...)'
ver_7.cpp:12: implicit declaration of function `int calculate_fun(...)'
ver_7.cpp:13: implicit declaration of function `int printFun(...)'

ver_8.cpp: In function `int main()':
ver_8.cpp:7: `DistanceOfPoints' undeclared (first use this function)
ver_8.cpp:7: (Each undeclared identifier is reported only once
ver_8.cpp:7: for each function it appears in.)
ver_8.cpp:7: parse error before `;'
ver_8.cpp:8: `obj_1' undeclared (first use this function)

0
 
LVL 10

Accepted Solution

by:
Sys_Prog earned 500 total points
ID: 10810456
edelossantos,

Post the code which u compile and get these errors

Amit
0
 

Author Comment

by:edelossantos
ID: 10810476
// ver5.cpp
#include <iostream>
#include <cmath>

using namespace std;

void input fun(p_array);
double calculate fun(p_array);

int main() {


   double p_array[2][3]; // data structure, memory location for your variable
   double d;

   input fun(p_array);
   calculate fun(p_array);
   print fun(double d);

   d = calculation function;

   print fun(d);

   return 0;

}

ver5.cc:6: `p_array' was not declared in this scope
ver5.cc:6: variable or field `inputFun' declared void
ver5.cc:7: `p_array' was not declared in this scope
ver5.cc: In function `int main()':
ver5.cc:15: variable or field `inputFun' declared void
ver5.cc:15: initialization to `int' from `double (*)[3]' lacks a cast
ver5.cc:16: initialization to `double' from `double (*)[3]'
ver5.cc:17: parse error before `)'
ver5.cc:19: `calculation' undeclared (first use this function)
ver5.cc:19: (Each undeclared identifier is reported only once
ver5.cc:19: for each function it appears in.)
ver5.cc:19: parse error before `;'
ver5.cc:21: `print' undeclared (first use this function)

// ver_6.cpp
#include <iostream>

using namespace std;

void input_fun(double p_array[2][3]);
double calculate_fun(double p_array[2][3]);
void print_fun(double distance);

int main() {

   double p_array[2][3];
   double distance;

   input_fun(p_array);
   distance = calculate_fun(p_array);
   print_fun(distance);

   return 0;

}

void input_fun(double p_array[2][3]) {

   for(int i = 0; i <= 1; i++)
       for(int j = 0; j <= 2)
            cin >> p_array[i][j];

}

double calculate_fun(double p_array[2][3]) {

   double distance;
     
   distance =

   return distance;

}

void print_fun(double distance) {

   cout << "distance = " << distance << endl;

}

ver_6.cpp: In function `void input_fun(double (*)[3])':
ver_6.cpp:27: parse error before `)'
ver_6.cpp:38: parse error before `return'
ver_6.cpp:42: parse error before `{'

// ver_7.cpp
#include <iostream>

using namespace std;

int main()
{
   point p_array[2];
   double distance;
   inputFun(p_array);
   distance = calculate_fun(p_array);
   printFun(distance);

   return 0;

}

ver_7.cpp: In function `int main()':
ver_7.cpp:9: `point' undeclared (first use this function)
ver_7.cpp:9: (Each undeclared identifier is reported only once
ver_7.cpp:9: for each function it appears in.)
ver_7.cpp:9: parse error before `['
ver_7.cpp:11: `p_array' undeclared (first use this function)
ver_7.cpp:11: implicit declaration of function `int inputFun(...)'
ver_7.cpp:12: implicit declaration of function `int calculate_fun(...)'
ver_7.cpp:13: implicit declaration of function `int printFun(...)'

// ver_8.cpp
#include <iostream>

using namespace std;

int main()
{
   DistanceOfPoints obj_1;
   obj_1.inputFun();
   obj_1.calculateFun();
   obj_1.printFun();

   return 0;

}

ver_8.cpp: In function `int main()':
ver_8.cpp:7: `DistanceOfPoints' undeclared (first use this function)
ver_8.cpp:7: (Each undeclared identifier is reported only once
ver_8.cpp:7: for each function it appears in.)
ver_8.cpp:7: parse error before `;'
ver_8.cpp:8: `obj_1' undeclared (first use this function)










0
 

Author Comment

by:edelossantos
ID: 10810480
// ver5.cpp
#include <iostream>
#include <cmath>

using namespace std;

void input fun(p_array);
double calculate fun(p_array);

int main() {


   double p_array[2][3]; // data structure, memory location for your variable
   double d;

   input fun(p_array);
   calculate fun(p_array);
   print fun(double d);

   d = calculation function;

   print fun(d);

   return 0;

}

ver5.cc:6: `p_array' was not declared in this scope
ver5.cc:6: variable or field `inputFun' declared void
ver5.cc:7: `p_array' was not declared in this scope
ver5.cc: In function `int main()':
ver5.cc:15: variable or field `inputFun' declared void
ver5.cc:15: initialization to `int' from `double (*)[3]' lacks a cast
ver5.cc:16: initialization to `double' from `double (*)[3]'
ver5.cc:17: parse error before `)'
ver5.cc:19: `calculation' undeclared (first use this function)
ver5.cc:19: (Each undeclared identifier is reported only once
ver5.cc:19: for each function it appears in.)
ver5.cc:19: parse error before `;'
ver5.cc:21: `print' undeclared (first use this function)

// ver_6.cpp
#include <iostream>

using namespace std;

void input_fun(double p_array[2][3]);
double calculate_fun(double p_array[2][3]);
void print_fun(double distance);

int main() {

   double p_array[2][3];
   double distance;

   input_fun(p_array);
   distance = calculate_fun(p_array);
   print_fun(distance);

   return 0;

}

void input_fun(double p_array[2][3]) {

   for(int i = 0; i <= 1; i++)
       for(int j = 0; j <= 2)
            cin >> p_array[i][j];

}

double calculate_fun(double p_array[2][3]) {

   double distance;
     
   distance =

   return distance;

}

void print_fun(double distance) {

   cout << "distance = " << distance << endl;

}

ver_6.cpp: In function `void input_fun(double (*)[3])':
ver_6.cpp:27: parse error before `)'
ver_6.cpp:38: parse error before `return'
ver_6.cpp:42: parse error before `{'

// ver_7.cpp
#include <iostream>

using namespace std;

int main()
{
   point p_array[2];
   double distance;
   inputFun(p_array);
   distance = calculate_fun(p_array);
   printFun(distance);

   return 0;

}

ver_7.cpp: In function `int main()':
ver_7.cpp:9: `point' undeclared (first use this function)
ver_7.cpp:9: (Each undeclared identifier is reported only once
ver_7.cpp:9: for each function it appears in.)
ver_7.cpp:9: parse error before `['
ver_7.cpp:11: `p_array' undeclared (first use this function)
ver_7.cpp:11: implicit declaration of function `int inputFun(...)'
ver_7.cpp:12: implicit declaration of function `int calculate_fun(...)'
ver_7.cpp:13: implicit declaration of function `int printFun(...)'

// ver_8.cpp
#include <iostream>

using namespace std;

int main()
{
   DistanceOfPoints obj_1;
   obj_1.inputFun();
   obj_1.calculateFun();
   obj_1.printFun();

   return 0;

}

ver_8.cpp: In function `int main()':
ver_8.cpp:7: `DistanceOfPoints' undeclared (first use this function)
ver_8.cpp:7: (Each undeclared identifier is reported only once
ver_8.cpp:7: for each function it appears in.)
ver_8.cpp:7: parse error before `;'
ver_8.cpp:8: `obj_1' undeclared (first use this function)






0
 
LVL 4

Expert Comment

by:booki
ID: 10810501
edelossantos,

Are you trying to make one executable binary from multiple source files or 4 independent binaries?

I'm, guessing the former but just to be sure..

b.
0
 
LVL 4

Expert Comment

by:booki
ID: 10810508
edelossantos,

... hmm.. one second thought I'm really not sure what you're trying to do.  Please explain.

b.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:edelossantos
ID: 10810512
These are 4 independent binaries.
0
 

Author Comment

by:edelossantos
ID: 10810521
These are codes that have been given to me for correction.  There are 4 independent files.  I gravely need help in the correction of the actual codes.  In other words, the codes need to be corrected.  Please advise.
0
 
LVL 4

Expert Comment

by:booki
ID: 10810568
edelossantos,

I was just about to post but you've accepted already... You're questions been answered???

b.
0
 

Author Comment

by:edelossantos
ID: 10810584
No, I screwed up.  Send the solutions that I can grade you on.  I am still new at this engine! You will be given an A!
0
 
LVL 4

Expert Comment

by:booki
ID: 10810600
Ok,

Post to community support to have this question deleted and I will post to your other TA.

b.
0
 

Author Comment

by:edelossantos
ID: 10810617
How do you post to community support?
0
 
LVL 4

Expert Comment

by:booki
ID: 10810646
At the very top of this page you should see:

Careers | Site News | Support | Help

Click on Support and post a 0 point question with the subject "Please Delete" with a link to this question in the question body.

You'll get your points back too.

b.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now