0

Can someone tell me how to code on c for the area or rectangle in this app and pls give me the errors and correct code of below.

int main() { int maths,english,punjabi,physics,chemistry ; printf ("enter marks of maths "); scanf("%d",&marks ); printf ("enter marks of english \n"); scanf ("%d",&marks ); printf ("enter marks of punjabi \n"); scanf("%d",&marks ); printf ("enter marks of physics \n"); scanf("%d",&marks ); printf ("enter marks of chemistry \n "); scanf("%d",&marks ); int total =maths,english,punjabi,physics,chemistry printf ("marks is : %d" ,marks) ; return 0; }

18th Jul 2023, 5:02 AM
ANKIT RAJ
ANKIT RAJ - avatar
7 ответов
18th Jul 2023, 5:26 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 1
C does not allow us to declare variable anywhere apart the top of the function. So remove that line that says int total = ..... Declare "total" at the top level of the function and use it like total = "...."
18th Jul 2023, 5:07 AM
RuntimeTerror
RuntimeTerror - avatar
+ 1
In this code, input it correctly in 'scanf' according to the subjects, you total the marks of all the subject then use add operator '+' and then you can print the total marks of subjects. Hint: Area of rectangle Input the length of the rectangle Input the width of the rectangle Area of the rectangle formula: length * width
18th Jul 2023, 5:08 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 1
ANKIT RAJ this is not a platform to give you a readymade code, you can take help from google.
18th Jul 2023, 5:13 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
0
Sakshi can u pls write the full code for this area of rectangle for this app
18th Jul 2023, 5:11 AM
ANKIT RAJ
ANKIT RAJ - avatar
0
#include <stdio.h> int main() { int total=45+45+45+45+20 ; printf ("enter marks of maths "); scanf("%d",&marks ); printf ("enter marks of english \n"); scanf ("%d",&marks ); printf ("enter marks of punjabi \n"); scanf("%d",&marks ); printf ("enter marks of physics \n"); scanf("%d",&marks ); printf ("enter marks of chemistry \n "); scanf("%d",&marks ); printf ("total") ; return 0; } Can someone pls correct this 🤔code and tell me what's the error
18th Jul 2023, 5:15 AM
ANKIT RAJ
ANKIT RAJ - avatar
0
Remove comma between and put '+'.....declaration on or not it isn't matter coz c compiler check your code line be4 executing
18th Jul 2023, 7:33 AM
hassani s khamisi
hassani s khamisi - avatar