They are called functions.app
A syntax error is a violation of the rules governing how sentences or programs are put together. Here's an example in English:"Me speak English good." Here's an example in C.ide
printf"Where are the parentheses?";
A semantic error is one of meaning. Here's an example in English : " This sentence is excellent Czech." Here's a C example:this
thrice_n = 3 + n;
Line 1: Begin with a #; spell the file stdio.h; place the filename within angle brackets.spa
Line 2: Use() , not {}; end the comment with */, not /*.excel
Line 3: Use {, not (.code
Line 4: Complete the statement with a semicolon.orm
Line 5: Indiana got this one (the blank line) right!blog
Line 6: Use =, not := for assignment.(Apparently, Indiana knows a little Pascal.) User 52, not 56, weeks per year.get
Line 7: Should beit
printf("There are %d weeks in a year.\n", s);
Line 8: There isn't a line 9, but there should be, and it should consist of the closing brace, }.
a. printf("Baa Baa Black Sheep.");
printf("Have you any wool?\n");
b. printf("Begone!\nO creature of lard!\n");
c. printf("What?\nNo/nfish?\n");
d. int num;
num = 2;
printf("%d + %d = %d", num, num, num + num);
a: Baa Baa Black Sheep.Have you any wool? (Note that there's no space after the period. You could have had a space by using " have instead of "have.)
b: Begone!
O creature of lard! (Note that the cursor is left at the end of the second line.)
c: What?
No/nfish? (Note that the slash[/] does not have the same effect as the backslash [\]; it simply prints as a slash.)
int and char.
There were 3020 words and 350 lines.
Here, 3020 and 350 represent the values of the two variables.
printf("There were %d words and %d lines.\n", words, lines);
#include <stdio.h> int main(void) { int a, b; a = 5; b = 2; /* line 7 */ b = a; /* line 8 */ a = b; /* line 9 */ printf("%d %d\n", b, a); return 0; }
After line 7, a is 5 and b is 2. After line 8, both a and b are 5. After line 9, both a and b are still 5. (Note that a cant be 2 because by the time you say a = b; b has already been changed to 5.)
#include <stdio.h> int main(void) { int x, y; x = 10; y = 5; /* line 7 */ y = x + y; /* line 8 */ x = x * y; /* line 9 */ printf("%d %d\n", x, y); return 0; }
After line 7, x is 10 and y is 5. After line 8, x is 10 and y is 15. After line 9, x is 150 and y is 15.