Quiz
C Quiz - Linkedin
Este quiz tem tempo limite, por isso abre no player de sempre.
Perguntas do quiz (32)
1Which Code sample will eventually cause the computer to run out of memory ?
- Ac while(1) { char *smallString = (char *) malloc(10); } ```
- Bc long long number = 1; while(1) number *= 2; ```
- Cc while(1) { char hugeString[1000000L]; memset(hugeString, 0, 1000000L); } ```
- Dc while(1) { long *bigArray = (long *) malloc(sizeof(long) * 1000); memset(bigArray, 1000000, 1000); free(bigArray); } ```
2What will this code print on the screen?
int f1 (int a, int b)
{
if (a > b)
{
printf("A is greater than B\n");
return 1;
}
else
{
printf("B is greater than A");
return 0;
}
}
main()
{
if (f1(20,10) || f1(10,20))
printf("C is fun!\n");
}- AA is greater then B C is fun!
- BA is greater then B B is greater then A C is fun!
- CA is greater then B B is greater then A
- DNorthing is printed on Screen
3What is the name for calling a function inside the same function?
- Arecursion
- Bsubfunction
- Cinner call
- Dinfinite loop
4What does the declaration of variable c2 demonstrate?
main(){
char c1 ='a';
char c2 = c1+10;
}- Acharacter arithmetic
- Bundefined assignment
- Ctype conversion
- Dinvalid declaration
5 A pointer to void named vptr, has been set to point to a floating point variable named g. What is the valid way to dereference vptr to assign its pointed value to a float variable named f later in this program?
float g;
void *vptr=&g;- Af = _(float _)vptr;
- Bf = (float *)vptr;
- Cf = *(float *)vptr;
- Df = *(float)vptr;
6What is this declaration an example of?
struct s {
int i;
struct s *s1;
struct s *s2;
};- Aa node
- Ba linked list
- Ca stack
- Da binary tree
7A C header file is a file with extension .h that contains function declarations and macro definitons to be shared between several source files. Header files are listed using the preprocessing directive #include, and can have one of the following formats: #include <fileA> or #include "fileB". What is the difference between these two formats?
- AThe preprocessor will try to locate the fileA in same directory as the source file, and the fileB in a predetermined directory path.
- BThe preprocessor will try to locate the fileA in the fixed system directory. It will try to locate fileB in the directory path designated by the -l option added to the command line while compiling the source code.
- CThe file using fileA syntax must be system files, of unlimited number. fileB must be a user file at a maximun of one per source file.
- DThe preprocessor will try to locate the fileA in a predetermined directory path. It will try to locate fileB in the same directory as the source file along with a custom directory path.
8Using a for loop, how could you write a C code to count down from 10 to 1 and display each number on its own line?
- Ac for (int i = 0; i>=0, i--){ printf("%d\n", i); }//end of loop ```
- Bc int i; for (i=1; i<=10; i++){ printf("%d", i); } ```
- Cc int i = 10; while (i>0){ printf("%d\n", i); i--; } ```
- Dc int i; for (i= 10; i>0; i--){ printf("%d\n", i); }// end of loop ```
9What is not one of the reserved words in standard C?
- Avolatile
- Btypeof
- Cregister
- Dtypedef
10What does the program shown below return?
int main(){
int a=1, b=2, c=3, d=4;
int x = a;
if (a>b)
if (b<c) x=b;
else x=c;
return(x);
}- A1
- B3
- C2
- D0
11Using the Union declaration below, how many bytes of memory space will the data of this type occupy?
union Cars {
char make[20];
char model[30];
short year;
} car;- A32
- B54
- C30
- D52
12In this code sample, what is not a problem for C compiler?
main(){
constant int PI = 3.14;
printf("%f\n", pi);
}- AThe value of PI needs to be set to 3.141593, not 3.14
- BThe declaration of PI needs to say const, not constant.
- CThe data type of PI needs to be float not int.
- DThe printf statement needs to use PI, not pi.
13Which is the smallest program to compile and run without errors?
- Amain()
- Bint main() {return 0;}
- Cmain() { }
- Dmain() { ; }
14 What is optional in a function declaration?
- Adata type of parameters
- Breturn type of function
- Cparameter names
- Dnumber of parameters
15C treats all devices, such as the display and the keyboard, as files. Which files opens automatically when a program executes?
- Astdout
- Bstdio.h
- Cdefault.h
- Dstring.h
16 In which segment does dynamic memory allocation takes place?
- ABSS Segment
- Bstack
- Cheap
- Ddata segment
17Which of the following do you use to deallocate memory?
- Adalloc()
- Bdealloc()
- Crelease()
- Dfree()
18 In C language what are the basic building blocks that are constructed together to write a program?
- Akeywords
- Bidentifiers
- Ctokens
- Dfunctions
19When is memory for a variable allocated?
- Aduring the assigment of the variable
- Bduring the initialization of the variable
- Cduring the declaration of the variable
- Dduring the definition of the variable
20By default c uses the call by value method to pass arguments to functions. How can you invoke the call by reference method?
- Aby using pointers
- Bby declaring functions separately from defining them
- Cby using recursive functions
- Dby using global variables
21A union allows you to store different ___ in the same ___.
- AObjects; Structure
- BVariables; Declaration
- CData types; Memory location
- DArrays; Header file
22What is the output of this program?
main() {
char c1='a' , c2='A';
int i=c2-c1;
printf("%d", i);
}- A32
- Bruntime error
- C-32
- D0
23What is the difference between scanf() and sscanf() functions?
- AThe scanf() function reads data formatted as a string; The sscanf() function reads string input from the screen.
- BThe scanf() function reads formatted data from the keyboard; The sscanf() function reads formatted input from a string.
- CThe scanf() function reads string data from the keyboard; The sscanf() function reads string data from a string.
- DThe scanf() function reads formatted data from a file; The sscanf() function reads input from a selected string
24What is not a valid command with this declaration?
char *string[20] = { "one", "two", "three"};- Aprintf("%c", string[1][2]);
- Bprintf("%s", string[1][2]);
- Cprintf("%s", string[1]);
- Dprintf(string[1]);
25What is the expression player->name equivalent to?
- Aplayer.name
- B(*player).name
- C*player.name
- Dplayer.*name
26Which program will compile and run without errors?
- Ac main() { for(i=0; i<10; i++) ; } ```
- Bc main() { int i=0; for(; i<10; i++) ; } ```
- Cc main() { int i; for(i=0; i<j; i++) ; } ```
- Dc main() { int i; for (i= 10; i<10; i++) } ```
27What does this function call return?
1 main() { float x = f1(10, 5); }
2 float f1(int a, int b) { return (a/b); }- A2
- B2.000000
- Ca runtime error
- Da compiler error
28What does this program create?
#include <stdio.h>
int main() {
int *p = NULL;
return 0;
}- Aa runtime error
- Ba NULL pointer
- Ca compile error
- Da void pointer
29What is an alternative way to write the expression (*x).y?
- AThere is no equivalent.
- Bx->y
- C*x->y
- Dy->x
30Compile time errors are static errors that can be found where in the code?
- Ain declarations and definitions
- Bin functions and expressions
- Cin syntax and semantics
- Din objects and statements
31File input and output (I/O) in C is heavily based on the way it is done ___?
- Ain Unix
- Bin C++
- Cin C#
- Din DOS
32What does the strcmp(str1, str2); function return?
- A0 if str1 and str2 are the same, a negative number if str1 is less than str2, a positive number if str1 is greater than str2
- Btrue (1) if str1 and str2 are the same, false (0) if str1 and str2 are not the same
- Ctrue (1) if str1 and str2 are the same, NULL if str1 and str2 are not the same
- D0 if str1 and str2 are the same, a negative number if str2 is less than str1, a positive number if str2 is greater than str1
Informações
- Descrição
- https://github.com/Ebazhanov/linkedin-skill-assessments-quizzes/blob/master/c-(programming-language)/c-quiz.md
- Autor
- Bianca Alexandra
- Idioma
- English
- Visualizações
- 14
- Avaliação
- Ainda sem avaliações Avalie este quiz