Register to reply

Error in code

by andonibmp
Tags: code, error
Share this thread:
Jan22-12, 06:51 PM
P: 2
hey im doing a intro programming class and Im running into some problems. would really appreciate some help to see where I went wrong. Been trying to figure it out for hours now. Someone please help me out
These are my errors
c: In function ‘main’:
c:33:9: error: expected identifier or ‘(’ before ‘=’ token

This is the code:

#include <stdio.h>
#include <math.h>

int main (void)
float distance;

int x1,x2;
int y1,y2;

printf("The three types of angles in triangles are: Right angles,Obtuse Angles, and Acute angles") ;

printf("Three kinds of triangles are: Equilateral Triangles,Isosceles Triangles and Scalene Triangles") ;

printf(" The Pythagorean Theorem is : a2+b2=c2") ;

printf("The Distance Formula is: sqrt(pow(x2-x1,2) + pow(y2-y1,2)") ;

printf("Please enter First X value") ;
scanf("%d",&x1) ;

printf("Please enter Second X Value") ;
scanf("%d",&x2) ;

printf("please enter First Y Value") ;
scanf("%d",&y1) ;

printf("Please enter Second Y Value") ;
scanf("%d",&y2) ;

float=sqrt(pow(x2-x1,2) + pow(y2-y1,2);

printf("Distance is %f",distance);

return 0;
Phys.Org News Partner Science news on
Fungus deadly to AIDS patients found to grow on trees
Canola genome sequence reveals evolutionary 'love triangle'
Scientists uncover clues to role of magnetism in iron-based superconductors
Jan22-12, 07:19 PM
jtbell's Avatar
P: 11,749
Quote Quote by andonibmp View Post
float=sqrt(pow(x2-x1,2) + pow(y2-y1,2);
I think you meant to put something other than "float" there. Also, check your parentheses while you're at it.
Jan22-12, 09:44 PM
P: 2
I have no idea what else to put there I keep getting errors.

Jan22-12, 09:46 PM
P: 55
Error in code

float is a data type you need to use a variable name of type float, also make sure your parens are equal to eachother for example this

distance=sqrt(pow(x2-x1,2) + pow(y2-y1,2));

P.S. throw some '\n' in your printf statements so it is not as cluttered.
Jan23-12, 12:52 AM
P: 21,261
Quote Quote by andonibmp View Post
I have no idea what else to put there I keep getting errors.
Put a variable there.

You can't assign a value to a data type.

Also, see jtbell's post - you have a problem with your parentheses on that line.

Register to reply

Related Discussions
Error Correction Code tip? Electrical Engineering 3
Error Correcting Code understanding Linear & Abstract Algebra 0
Need help ...verilog code error Electrical Engineering 0
Spot the error in my code. (in C). Programming & Computer Science 11
Convolution Code and Error Correcting Capability Electrical Engineering 2