Question

syntactically correct but semantically incorrect examples in programming?

syntactically correct but semantically incorrect examples in programming?

Homework Answers

Answer #1

Syntactically and semantically. Syntactically means grammatically wrong. In any language if syntax is not valid that comes under syntactically wrong. But if some thing is semantically wrong it means that the syntax is acceptable but meaningless.

For ex:

#include<stdio.h>
int main(){
int x;
printf("%d",x);
}

We define x but there is no any value of x so it can be anything which is called garbage value.

#include<stdio.h>
int main(){
int x;
printf("%d",x)
}

Semicolon is missing in line 4 so this is syntactically wrong.

Another example

#include<stdio.h>
int main(){
int add(int x, int y){
return x-y;
}
printf("%d",add(3,4));
}

This is also semantically wrong but syntactically correct because the add function in the program is for adding purpose but used for finding difference.

Know the answer?
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
Similar Questions
Circle “Correct” or “Incorrect” for the following 10 questions. For problems with incorrect answers, provide a...
Circle “Correct” or “Incorrect” for the following 10 questions. For problems with incorrect answers, provide a rationale to support your answer. 1. In administering insulin, the nurse will use the 100 units/mL listed on the drug label to calculate the dose. Correct Incorrect    , Rationale: 2. .U-100 on the insulin label refers to the insulin concentration. Correct Incorrect    Rationale: 3. The physician orders Humalog 6 units subcut now. The nurse has a vial of Novolog insulin. The nurse...
Explain how methods are useful in Programming in General. Provide Examples.
Explain how methods are useful in Programming in General. Provide Examples.
“The balance budget multiplier is equal to zero”. Is this statement correct or incorrect? Define the...
“The balance budget multiplier is equal to zero”. Is this statement correct or incorrect? Define the balanced budget multiplier and then explain your answer.
Choose the correct answer and explain each answer why it is correct/incorrect 10/Total surplus in a...
Choose the correct answer and explain each answer why it is correct/incorrect 10/Total surplus in a market will increase when the government imposes a tax on that market.    imposes a binding price floor on that market. removes a binding price ceiling from that market. None of these statements is correct 9/Which of the following will cause an increase in producer surplus?   the imposition of a binding price ceiling in the market    buyers expect the price of the good to be...
Random assignment explain which one is correct and which one is incorrect Can be achieved by...
Random assignment explain which one is correct and which one is incorrect Can be achieved by flipping a coin or using a random number table/generator Requires that every person in the sample has an equal probability of being assigned to any condition. Is used to achieve the goal of initial equivalence a & b & c are correct a & c are correct
  Random assignment explain which one is correct and which one is incorrect Can be achieved by...
  Random assignment explain which one is correct and which one is incorrect Can be achieved by flipping a coin or using a random number table/generator Requires that every person in the sample has an equal probability of being assigned to any condition. Is used to achieve the goal of initial equivalence a & b & c are correct a & c are correct
Draw the structures of the following compounds. If the name provided is incorrect, give the correct...
Draw the structures of the following compounds. If the name provided is incorrect, give the correct name. a. pentoxyethane                      b. 3-chloro-4-methyl-6-heptyne                       c. 2-ene-4-octyne d. 3,4,5-pentanetriol                    e. 1-Methylcyclopentanol                                                      f. 1,3,5-cyclohexatriene
Solve the linear programming problem by the simplex method. (There may be more than one correct...
Solve the linear programming problem by the simplex method. (There may be more than one correct answer.) Maximize P = 5x + 5y + 6z subject to x + y + 5z ≤ 25 6x + 6y + 5z ≤ 220 x ≥ 0, y ≥ 0, z ≥ 0
a) Write about the correct and incorrect sides Canbay`s Theory on the etiology of Multiple Sclerosis...
a) Write about the correct and incorrect sides Canbay`s Theory on the etiology of Multiple Sclerosis disease, giving supporting with scientific evidences what you have written. b)Add your views on the etiology of Multiple Sclerosis disease.
How many significant figures do the following numbers contain? 1.001 4 Correct: Your answer is correct....
How many significant figures do the following numbers contain? 1.001 4 Correct: Your answer is correct. 3.45 3 Correct: Your answer is correct. 3.450 4 Correct: Your answer is correct. 0.01 1 Correct: Your answer is correct. .010 2 Correct: Your answer is correct. 1.230e-04 6 Incorrect: Your answer is incorrect. 0.11e-04 6 Incorrect: Your answer is incorrect. 1.233 + .1 4 Incorrect: Your answer is incorrect. 1.233*.1 4 Incorrect: Your answer is incorrect. 1.233/.01 4 Incorrect: Your answer is...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT