KEMBAR78
C Prog | PDF
0% found this document useful (0 votes)
9 views2 pages

C Prog

The document contains C code snippets for calculating the area of a rectangle and a circle. It highlights common errors such as undeclared variables and redeclaration of variables. The code includes user input for dimensions and outputs the calculated areas.

Uploaded by

harshitmu57
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

C Prog

The document contains C code snippets for calculating the area of a rectangle and a circle. It highlights common errors such as undeclared variables and redeclaration of variables. The code includes user input for dimensions and outputs the calculated areas.

Uploaded by

harshitmu57
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

error: ‘lenght’ undeclared (first use in this function); did you mean ‘length’?

answer length

#include <stdio.h>

int main()

//declare the variables

float length,breadth,area;

//take inputs from the user

printf("please enter the value for length: ");

scanf("%f",&length);

printf("please enter the value for breadth: ");

scanf("%f",&breadth);

//calculate the results

area=length*breadth;

//output the calulated results

printf("the area of a rectangle is %f",area);

return 0;

error: redeclaration of ‘r’ with no linkage

5| float area,pie,r,r;

| ^

main.c:5:23: note: previous declaration of ‘r’ with type ‘float’

5| float area,pie,r,r;
| ^

#include <stdio.h>

int main()

//declare the variable

float radius,area;

float const PI=3.14;

//take input from the user

printf("Enter the radius of the circle: ");

scanf("%f", &radius);

//process the input

area = PI * radius * radius;

//output

printf("The area of the circle is: %.2f\n", area);

return 0;

You might also like