c programming language linkedin assessment answers
1. What is not a valid command with this declaration?
char *string(20] = ‹"one"
"two
"three"}
- printf(“&s”, string{1]);
- printf (“&c”, string(1](2]) ;
- printf(“&s”, string{1][2]) ;
- printf(string(l]);
2. What is the name for calling a function inside the same function?
- infinite loop
- inner call
- nested function
- recursion
4. String variable str1 has the value of "abc", and string variable str2 has the value of "xyz". What are the values of str1 and str2 after this statement is executed?
strepy (strl, str2) ;
- strl: “xyz”
str2: “yvz” - strl: “xyz”
str2: “abc” - strl: “abc”
str2: “xyz” - strl: “abc”
str2: “abc”
6. C uses the call by value method to pass arguments to functions. How can you invoke the call by reference method?
- by using pointers
- by using recursive functions
- by declaring functions separately from defining them
- by using global variables
7. Which is not a correct way to declare a string variable?
- char string[] =
“Hello World”; - char *string = “Hello World”;
- char string[20] = {‘H’, ‘e’, ‘l’, ‘l’, ‘o’, ‘ ‘, ‘w’, ‘o’, ‘r’, ‘l’ ‘d’, ‘\0’};
- char string = “Hello World”;
8. You have written a function that you want to include as a member of structure a. How is such a structure member defined?
- struct a {
void *f1;
}; - struct a {
void *f1(): }; - struct a {
void (*f1) ();
}; - struct a {
* (void f1) ();
}:
9. Which is the smallest program to compile and run without errors?
- main()
- int main() { return 0; }
- main() {;}
- main(){}
10. Void pointer vptr is assigned the address of float variable g. What is a valid way to dereference vptr to assign its pointed value to a float variable named f later in the program?
float g;
void
*vptr=&g:
- f=*(float *) vptr:
- f=* (float) vptr;
- f=(float * )vptr;
- f=(float) *vptr;
12. A union allows you to store different _____ in the same _____.
- variables; declaration
- obiects: structure
- arrays; header file
- data types; memory space
13. How many times does the code inside the while loop get executed in this program?
- 100
- 3
- 5
- 50
15. How are static functions different from global functions?
- Static functions must be declared in a separate header file.
- Static functions can be accessed only in the file where they are declared.
- Static functions must be declared in advance of being defined.
- Static functions always return the same value.