Hi,
I created a C program for the Casio Prizm, but I can not compile it. What am I doing wrong?
The program is to add two vectors. This is the program:


Code:
#include <display_syscalls.h>
#include <keyboard_syscalls.h>
void main(void)
{
int c[10];
int e;
public:
   void inicia (void);
   void pon_dato(int i);
   void suma(Vector x, Vector y );
   void Visualizar(void);
} ;

Vector r;

void Vector::inicia(void)
{
 e=0;
}

void Vector::pon_dato(int i)
{
c[e++]=i;
}


 

void Vector::Visualizar(void)
{
 short j;
 for(j=0;j<e;j++)
 cout <<"  " << c[j];
 cout << endl;
}

void Vector::suma(Vector x, Vector y)
{
  short j;
  if (x.e != y.e)
cout << "No se pueden sumar los vectores" << endl;
  else  for(j=0;j<x.e;j++)
      r.c[j] = x.c[j]+y.c[j];
    cout << endl;
   r.e=x.e;
}


int main(void)  {
 Vector a,b;
 short opc,dato;
 a.inicia();
 b.inicia();
  do {
    cout << "Menu \n";
    cout << "1. Inserta en el Vector A  \n";
    cout << "2. Inserta en el Vector B  \n";
    cout << "3. Visualiza Datos  \n";
    cout << "4. Suma de vectores \n";
    cout << "5. Salida \n";
    cout << "Da la opcion: ";
    cin >> opc;
     switch (opc)   {
         case 1:   cout << "Da el dato ";
                cin >> dato;
                a.pon_dato(dato);
                break;
         case 2:   cout << "Da el dato ";
                cin >> dato;
                b.pon_dato(dato);
                break;
         case 3:   a.Visualizar();
               b.Visualizar();
               break;
         case 4:  r.suma(a,b);
               r.Visualizar();
               break;
             }
       }while (opc!=5);
 return 0;
}
Welcome to Cemetech, luis. Be sure to Introduce Yourself when you get a chance. I have edited your post to make it use [code] rather than [quote] tags; let's take a look. It seems you have written a C++ program rather than a C program, and that you have combined pieces of a class declaration into your main() function (for starters). You have two main() functions, one at the top and one at the bottom. Did you write this program yourself from scratch, or did you use code from another source? What is the objective of this program? Are you using the PrizmSDK to build it?
thanks for your answer. I wrote this program and its functionality is to add two vectors. And yes I am using the SDK.
Do I have to write it again? What suit do you recommend to write programs?
When you want it to add two vectors, do you want it to add two vectors that you specify on-calc, or to only add two that you program in at the beginning? It looks like you won't have to rewrite it into C, but you will have to fix the problems like having two main()'s and mixing the visibility ("public:") things into main. I second Kerm's questions:
Quote:
Did you write this program yourself from scratch, or did you use code from another source? What is the objective of this program?
As far as a suite for writing programs, I use Notepad++ as my editor, with the PrizmSDK as my compiler. I think you also need to decide if you're writing C or C++, as this is a mish-mosh of the two.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement