Question




1(a) The following segment of code contains at least three (3) syntax errors that will compilation to fail with errors. Ident
1(a) The following C program contains three (3) syntax errors that will cause the compiler to generate error messages. Identianswer two question,each question has 3syntax errors,find it.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

For Q1:

#include <stdio.h>

void main (void){
float height,length; //declare length
float area;
printf( "input height of the rectangle: " );
scanf( "%f" ,&height);
printf( "input length Of the rectangle: " ); //end this print statement with ";"
scanf( "%f" ,&length); //error here %f to be used here
area = length*height ;
printf( "area of rectangle %f high and &f long is %f\n",height, length, area ) ;
//use " at the start of the string (area of...)
}

For Q2:

#include <stdio.h>
#include <math.h>
int main() { // enclose main() with "{"
   double value,result; /*use val instead of value here since variable used below is value and NOT val*/
   const double factor = 1.0/3.0;
   scanf("%lf",&value);
   result = pow(value,factor);
   printf("result is:%lf",result); //use printf insttead of print here since printf is used to print in java
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
answer two question,each question has 3syntax errors,find it. 1(a) The following segment of code contains at...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • /* •   The following code consists of 5 parts. •   Find the errors for each part...

    /* •   The following code consists of 5 parts. •   Find the errors for each part and fix them. •   Explain the errors using comments on top of each part. */ #include <stdio.h> #include <string.h> int main( ) { ////////////////////////////////////////////////////////////////////////// //////////////        Part A. (5 points)                ////////////////// int g(void) { printf("%s", Inside function g\ n " ); int h(void) {       printf(" % s ", Inside function h\ n "); } } printf("Part A: \n "); g(); printf(" \n"); ////////////////////////////////////////////////////////////////////////// //////////////       ...

  • I am trying to change my code so i no longer need the function that reads...

    I am trying to change my code so i no longer need the function that reads in the users base and height input but rather uses the implementation of argument vector in C. I want to accept command line arguments and have it calculate my area. so i want to type this into the command line and have it calculate my area project1 5 4 #include <stdio.h> void userDimensions(float *base, float *height) { scanf("%f", base); scanf("%f", height); } float calcArea(float...

  • help KKKL1164 4. The C program presented below has some syntax and logic errors. Analyse it...

    help KKKL1164 4. The C program presented below has some syntax and logic errors. Analyse it and highlight the errors, explaining how the errors can be corrected. This program attempts to solve a quadratic equation. #include <stdio.h> #include <math.h> int Main() const int a, b, Ci double doro, disc printf ("Lets find the root (s) of a printf ("ax 2 bx c. \n"); printf ("Please enter the coefficient a: scanf ("d", &c); printf ("Please enter the coefficient b: "); scanf...

  • Identify the errors in this C program (struct - calculating volume, area of cylinder). Explain. #include...

    Identify the errors in this C program (struct - calculating volume, area of cylinder). Explain. #include <stdio.h> #define PI 3.14 typedef struct cylinder{    float r,h;    float areacircle=2*PI*r;    float areacylinder;    float volumecylinder;    areacylinder=2*PI*r*h+2*PI*r*r;    volumecylinder=PI*r*r*h; }; int main() {    float start,numcyls;    printf("How many cylinders do you want? Enter a positive integer.\n");    scanf("%f",&numcyls);    if(numcyls<1||ceilf(numcyls)!=numcyls)    while()    {printf("The number you have entered is not a positive integer. Please try again.\n");        printf("Remember,...

  • NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A...

    NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A FUNCTION.   Problem are explained in bold #include <stdio.h> #include <string.h> #include <stdlib.h> #define pi 3.1415 void Area (double n); void VolSphere (double n); void Circumference (double n); void AllCalc (); // i dont know if the declaration of the function is correct AllCalc = AllCalculations //function main begins program execution int main (void) { puts("-Calculating Circle Circumference, Circle Area or Sphere Volume-\n"); void (*f[4])...

  • C program Classwork_3.3: Correct the program below that will read two numbers: number of drinks and...

    C program Classwork_3.3: Correct the program below that will read two numbers: number of drinks and number of sandwiches, and display the total bill calculated as: Total bill = Number of Drinks X 5.50 + Number of Sandwiches X 10.00 Answer the questions below. C-Program with error: Write the correct program here: #include<stdio.h> int main (void) floats numberofDrinks, numberofSandwiches; float totalBilling: printf("Enter number of Drinks \n"); scanf("%d",&numberofdrinks); printf("Enter number of Sandwiches\n") scanf("%f",&numberofSandwiches); totalbilling = numberofDrinks *5.50 + numberofsandwiches/10.00; printf("Total bill...

  • I wrote a program which computes the area and perimeter of a square, circle, or rectangle. As you will see in my main function, there is a for loop in which the user is supposed to be able repeat the...

    I wrote a program which computes the area and perimeter of a square, circle, or rectangle. As you will see in my main function, there is a for loop in which the user is supposed to be able repeat the program until they enter "q" to quit. However, my program runs through one time, the prompt appears again, but then it terminates before the user is allowed to respond to the prompt again. I'm not able to debug why this...

  • Please, I need help, I cannot figure out how to scan variables in to the function...

    Please, I need help, I cannot figure out how to scan variables in to the function prototypes! ******This is what the program should look like as it runs but I cannot figure out how to successfully build the code to do such.****** My code: #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <conio.h> float computeSeriesResistance(float R1, float R2, float R3); float computeParallelResistance(float R1, float R2, float R3); float computeVoltage(int current, float resistance); void getInputR(float R1, float R2, float R3); void getInputCandR(int...

  • I am trying to write C programming code and output will be as below but I...

    I am trying to write C programming code and output will be as below but I donno how to get the result analysis part. help me to add the 2nd part with my code: here is my code below: #include <stdio.h> #define MAX 100 struct studentMarkVariable{ int id; float marks; }; void getData(struct studentMarkVariable arrs[]); void show(struct studentMarkVariable arrs[]); int main() { printf ("####### Marks Analyzer V3.0 ####### \n");       struct studentMarkVariable arrs[MAX];     getData(arrs);     show(arrs); return 0; }...

  • Programming: Java: Fixing errors in code help: The errors are in square.java and rectangle.java and they...

    Programming: Java: Fixing errors in code help: The errors are in square.java and rectangle.java and they both say: constructor Shape in class Shape cannot be applied to given types; required: no arguments found: String reason: actual and formal argument lists differ in length The directions say: The files Shape.java and TestArea.java have been finished already, YOU DONT ADD ANYTHING TO THESE TWO. According to the requirement, you need to modify in Square.java and Rectangle.java, respectively a. Implementing constructor with no...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT