1. Yes, a warning message is generated by the compiler because main() is not returning a value. Add return 0; at the end of the main() function to remove the error.
2. (a) #include<stdio.h>
(b) Parkinson's Law:
Work expands so as to fill the time
available for its completion.
3. #include<stdio.h>
int main(void)
{
int height=8, length=12, width=10, volume;
volume = height * length * width;
printf("Dimensions: %dx%dx%d\n", length, width, height);
printf("Volume (cubic inches): %d\n",volume);
printf("Dimensional weight (pounds): %d\n", (volume + 165)/166);
return 0;
}
4. #include<stdio.h>
int main(void)
{
int a,b,c,d,e;
float f,g,h,i,j;
printf("%d %d %d %d %d %f %f %f %f %f", a,b,c,d,e,f,g,h,i,j);
return 0;
}
No all the values printed have no pattern among them. They are just garbage values.
5. 100bottles is not a legal identifier because identifiers should start with a letter or an underscore.
6. Underscores are added in identifiers just for legibility so that we can separate two words. Putting more than one adjacent underscore may create a burden to the programmer. If same identifier repeats at many places in a program you have to use same number of underscores every time in that identifier (If by mistake one identifier is missed, it will cause error(s) in the program).
7. for & while are keywords in C.
8. There are 14 tokens in this statement:
Identifiers: 4 which are answer q p p
Operators: 5 which are = * - * /
Constants: 2 which are 3 3
Punctuation: 3 which are ( ) ;
9. answer = ( 3 * q - p * p ) / 3 ;
10. Spaces which are essential are:
* int main(void) (Between int and main(void)
* int height (During declaration of variables between int and height)
No comments:
Post a Comment