nana91 Posted March 5, 2012 Report Share Posted March 5, 2012 Olá pessoal tenho este exercício que calcula a área regular de um polígono: #include <stdio.h> #include <stdlib.h> #include <math.h> #define PI 3.14 double area_regular_polygon (int n_sides, double length) { return 0.5 * (n_sides) * length^2 * sin(2*PI/n_sides); } void exercise_1_15 (void); int main (void) { exercise_1_15 (); return 0; } void exercise_1_15 (void) { int n_sides; double length; while (scanf ("%d%lf", &n_sides, &length) != EOF) { double z = area_regular_polygon (n_sides, length); printf ("%0.6f\n", z); } } E tenho os seguintes erros: c(28): error C2296: '^' : illegal, left operand has type 'double' c(28): error C2297: '^' : illegal, right operand has type 'double' c(28): warning C4033: 'area_regular_polygon' must return a value Como é que resolvo esta situação? Obgd. Link to comment Share on other sites More sharing options...
mjamado Posted March 5, 2012 Report Share Posted March 5, 2012 O operador ^ não é potência; é a operação binária XOR. Edit: aletracao de titulo (pmg) "Para desenhar um website, não tenho que saber distinguir server-side de client-side" - um membro do fórum que se auto-intitula webdesigner. Temo pelo futuro da web. Link to comment Share on other sites More sharing options...
pmg Posted March 5, 2012 Report Share Posted March 5, 2012 Multiplica por ele proprio (length * length), ou usa a funcao pow(). What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now