Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Dimension error in procedure


  • Please log in to reply
5 replies to this topic

#1 marreco

marreco

    CC Newcomer

  • Member
  • PipPip
  • 13 posts
  • Programming Language:Delphi/Object Pascal

Posted 14 October 2012 - 05:08 PM

Hi.

I'm in class 'Procedure'

By creating a program using 'Procedure', I'm trying a mistake.

Anyone know how to fix this error?

Semantic error at line 3
The number of dimensions for dance is wrong!

Program Erro_3_Line;
Procedure MIdade;
Var i, MIdade:Integer;
Soma:Real;
Begin
	 For i:= 1 To 5 Do
Writeln('Digite a Idade ', i);
	 Readln(MIdade[i]);
	 Soma:= Soma + MIdade[i];
	 Writeln('A som e..:',Soma:2:2);
	 Readln
End;

Procedure FIdade;
Var i, FIdade:Integer;
Soma:Real;
Begin
	 For i:= 1 To 7 Do
Writeln('Digite a Idade ', i);
	 Readln(MIdade[i]);
	 Soma:= Soma + MIdade[i];
	 Writeln('A som e..:',Soma:2:2);
	 Readln
End;
Var Opcao:Char;
Begin
Writeln('Escolha sua Operacao');
Writeln('M - Masculino');
Writeln('F - Feminino');
Readln(Opcao);
	 If Opcao = 'M' Then
	 Begin
	 MIdade;
End
Else If Opcao = 'F' Then
Begin
FIdade;
End
Else
Writeln('Opcao invalida!...');

End.

Write an algorithm that ask the user to **, and if it is the male **, ask 5 times the age of 5 different people's ** Male and show the sum of them.
However, if the user is ** Feminio ask the age of 7 times and show the sum of them.


  • 0

#2 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts
  • Programming Language:PHP, Delphi/Object Pascal, Pascal, Transact-SQL
  • Learning:C, Java, PHP

Posted 15 October 2012 - 02:33 AM

emantic error at line 3


This one is easy. It was clash between your procedure name (MIdade) and local variable name (also MIdade). You can not do this.

The number of dimensions for dance is wrong!


And what is this "dance"? It's not declared or used anywhere in the codes.

As with the last quote: sorry, too many ** there. I could not understand the problem. Please correct these **.
  • 0

#3 marreco

marreco

    CC Newcomer

  • Member
  • PipPip
  • 13 posts
  • Programming Language:Delphi/Object Pascal

Posted 15 October 2012 - 02:58 PM

Hi.

Write an algorithm That user is ask the man or woman, and if it is the man, ask 5 times the age of 5 different people's, if man and show the sum of Them.
However, if the user is woman ask the age of 7 times and show the sum of Them.


  • 0

#4 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts
  • Programming Language:PHP, Delphi/Object Pascal, Pascal, Transact-SQL
  • Learning:C, Java, PHP

Posted 16 October 2012 - 05:20 AM

Ic,

Basically the sample codes already had good algorithm. It only has minor problems, like for example the name clash that I mentioned, incorrect variable type (pay special attention to how variable MIdade used in the codes - this should give you good idea of what is the correct type for it).
  • 0

#5 marreco

marreco

    CC Newcomer

  • Member
  • PipPip
  • 13 posts
  • Programming Language:Delphi/Object Pascal

Posted 20 October 2012 - 03:42 PM

Hi.how can I create a "Array" in this code?
  • 0

#6 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts
  • Programming Language:PHP, Delphi/Object Pascal, Pascal, Transact-SQL
  • Learning:C, Java, PHP

Posted 23 October 2012 - 10:25 PM

The same way like you declared the age array in your earlier thread.
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download