LinkedIn skill assessment answers and questions – C (لغة برمجة)
C is one of the most popular and widely used programming languages in the world. It is also a common choice for LinkedIn skill assessments, which test your knowledge and proficiency in various topics related to C. If you are preparing for a LinkedIn skill assessment in C, or you just want to learn more about this powerful language, you might be interested in the following questions and answers.
They cover some of the most important and frequently asked concepts in C, such as data types, المؤشرات, المصفوفات, المهام, أكمل برمجة ARM Cortex-M Bare-Metal, و اكثر. By reading and understanding these questions and answers, you will not only improve your chances of passing the تقييم مهارات لينكد إن, but also gain a deeper insight into the fundamentals of C programming.
Q1. Which Code sample will eventually cause the computer to run out of memory?
- :
while(1)
{
char *smallString = (char *) malloc(10);
}
- :
long long number = 1;
while(1)
number *= 2;
- :
while(1)
{
char hugeString[1000000L];
memset(hugeString, 0, 1000000L);
}
- :
while(1)
{
long *bigArray = (long *) malloc(sizeof(long) * 1000);
memset(bigArray, 1000000, 1000);
(bigArray);
}
What will be the output of the code below?
Q2.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");
}
- :
A is greater than B
C is fun!
- :
A is greater than B
B is greater than A
C is fun!
- :
A is greater than B
B is greater than A
- Nothing is printed on Screen
What is the name for calling a function inside the same function?
Q3.- recursion
- subfunction
- inner call
- infinite loop
What does the declaration of variable c2 demonstrate?
Q4.main(){
char c1 ='a';
char c2 = c1+10;
}
- character arithmetic
- undefined assignment
- type conversion
- invalid declaration
What is this declaration an example of?
Q5.struct s {
int i;
struct s *s1;
struct s *s2;
};
- a node
- a linked list
- a stack
- a binary tree
Header files are listed using the preprocessing directive #include, and can have one of the following formats: #تتضمن <fileA> or #include “fileB”. What is the difference between these two formats?
Q6.- The preprocessor will try to locate fileA in the same directory as the source file, and the fileB in a predetermined directory path.
- The preprocessor will try to locate fileA in the fixed system directory. It will try to locate fileB in the directory path designated by the -I option added to the command line while compiling the source code.
- The file using the fileA syntax must be system files, of unlimited number; fileB must be a user file at a maximum of one per source file.
- The preprocessor will try to locate 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.
Using a for loop, how could you write a C code to count down from 10 إلى 1 and display each number on its own line?
Q7.- :
for (int i = 0; i>=0, i--){
printf("%d\n", i);
}//end of loop
- :
int i;
for (i=1; i<=10; i++){
printf("%d", i);
}
- :
int i = 10;
while (i>0){
printf("%d\n", i);
i--;
}
- :
int i;
for (i= 10; i>0; i--){
printf("%d\n", i);
}// end of loop
What is not one of the reserved words in standard C?
Q8.- متطايره
- typeof
- تسجيل
- typedef
What does the program shown below return?
Q9.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);
}
- 1
- 3
- 2
- 0
Using the Union declaration below, how many bytes of memory space will the data of this type occupy?
Q10.union Cars {
char make[20];
char model[30];
short year;
} car;
- 32
- 54
- 30
- 52
In this code sample, what is not a problem for C compiler?
سوف تحتاج إلى تحقيق ما لا يقل عن.main(){
constant int PI = 3.14;
printf("%f\n", pi);
}
- The value of PI needs to be set to 3.141593, ليس 3.14
- The declaration of PI needs to say const, not constant.
- The data type of PI needs to be float, not int.
- The printf statement needs to use PI, not pi.
Which is the smallest program to compile and run without errors?
س 12.- رئيسي()
- int main() {يعود 0;}
- رئيسي() { }
- رئيسي() { ; }
What is optional in a function declaration?
Q13.- data type of parameters
- return type of function
- parameter names
- number of parameters
C treats all devices, such as the display and the keyboard, as files. Which file opens automatically when a program executes?
س 14.- stdout
- stdio.h
- default.h
- string.h
In which segment does dynamic memory allocation take place?
س 15.- BSS Segment
- stack
- heap
- data segment
Which function do you use to deallocate memory?
س 16.- dalloc()
- dealloc()
- إطلاق سراح()
- مجانا()
In C language what are the basic building blocks that are constructed together to write a program?
Q17.- الكلمات الدالة
- identifiers
- tokens
- المهام
When is memory for a variable allocated?
س 18.- during the assignment of the variable
- during the initialization of the variable
- during the declaration of the variable
- during the definition of the variable
C uses the call by value method to pass arguments to functions. How can you invoke the call by reference method?
Q19.- by using pointers
- by declaring functions separately from defining them
- by using recursive functions
- by using global variables
A union allows you to store different ___
in the same ___
.
س 20. - أشياء; بناء
- الدورة الوحيدة لتعليم التواصل مع البرامج الأخرى لأكثر من; Declaration
- Data types; Memory space
- المصفوفات; Header file
What is the output of this program?
س 21.main() {
char c1='a' , c2='A';
int i=c2-c1;
printf("%d", i);
}
- 32
- Runtime error
- -32
- 0
What is the difference between scanf() and sscanf() المهام?
Q22.- The scanf() function reads data formatted as a string; The sscanf() function reads string input from the screen.
- The scanf() function reads formatted data from the keyboard; The sscanf() function reads formatted input from a string.
- The scanf() function reads string data from the keyboard; The sscanf() function reads string data from a string.
- The scanf() function reads formatted data from a file; The sscanf() function reads input from a selected string
What is not a valid command with this declaration?
Q23.char *string[20] = { "one", "two", "three"};
-
printf("%c", string[1][2]);
-
printf("%s", string[1][2]);
-
printf("%s", string[1]);
-
printf(string[1]);
What is the expression player->name equivalent to?
س 24.-
player.name
-
(*player).name
-
*player.name
-
player.*name
Which program will compile and run without errors?
Q25.- :
main() {
for(i=0; i<10; i++) ;
}
- :
main() {
int i=0;
for(; i<10; i++) ;
}
- :
main() {
int i;
for(i=0; i<j; i++) ;
}
- :
main() {
int i;
for (i= 10; i<10; i++)
}
What does this function call return?
س 26.1 main() { float x = f1(10, 5); }
2 float f1(int a, int b) { return (a/b); }
- 2
- 2.000000
- a runtime error
- a compiler error
What does this program create?
Q27.#include <stdio.h>
int main() {
int *p = NULL;
return 0;
}
- a runtime error
- a NULL pointer
- a compile error
- a void pointer
What is an alternative way to write the expression (*س).و?
س 28.- There is no equivalent.
- x->و
- *x->و
- y->س
Compile time errors are static errors that can be found in the code.
س 29.- in declarations and definitions
- in functions and expressions
- in syntax and semantics
- in objects and statements
File input and output (I / O) in C is heavily based on the way it is done ___
?
Q30. - in Unix
- in C++
- in C#
- in DOS
What does the strcmp(str1, str2); function return?
س 31.- 0 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
- صحيح (1) if str1 and str2 are the same, خاطئة (0) if str1 and str2 are not the same
- صحيح (1) if str1 and str2 are the same, NULL if str1 and str2 are not the same
- 0 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
What is the output of this program?
Q32.int a=10, b=20;
int f1(a) { return(a*b); }
main() {
printf("%d", f1(5));
}
- 100
- 200
- 5
- 50
Which is ليس 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'};
-
char string[] = "Hello World";
Which choice is an include guard for the header file mylib.h?
س 34.- :
#ifdef MYLIB_H
#undef MYLIB_H
// mylib.h content
#endif /* MYLIB_H */
- :
#ifndef MYLIB_H
#define MYLIB_H
// mylib.h content
#endif /* MYLIB_H */
- :
#define MYLIB_H
#include "mylib.h"
#undef MYLIB_H
- :
#ifdef MYLIB_H
#define MYLIB_H
// mylib.h content
#endif /* MYLIB_H */
How many times does the code inside the while loop get executed in this program?
تتم محاذاة كل طبقة وهذه كلها في نفس الوقت.main(){
int x=1;
while(x++<100){
x*=x;
if(x<10) continue;
if(x>50) break;
}
}
- 100
- 3
- 5
- 50
File input and output (I / O) in C is done through what?
Q36.- syntax-driven components
- native interfaces
- system objects
- function calls
Directives are translated by the?
Q37.- Pre-processor
- Compiler
- Linker
- Editor
The main loop structures in C programming are the for loop, the while loop, and which other loop?
Q38.- فعل…في حين
- إلى عن على…في
- repeat…حتى
- فعل…حتى
C Functions are what type of functions?
Q39. بشكل افتراضي,- عالمي
- static
- مكتبة
- النظام
You have written a function that you want to include as a member of structure ‘a’. How is such as structure member defined?
س 40.- :
struct a {
void *f1;
};
- :
struct a {
void (*f1)();
};
- :
struct a {
*(void *f1)();
};
- :
struct a {
void *f1();
};
A Stack data structure allows all data operations at one end only, making it what kind of an implementation?
س 41.- يصرف أولاً
- ليفو
- LILO
- LOLI
What does this program display?
س 42.main(){
char *p = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i;
for (i=0;i<5;i++) *p++; *p++;
printf("%c",*p++);
}
- ك
- M
- H
- G
Describe the relationship between lvalue and rvalue.
س 43.- An lvalue may appear only on the left-hand side of an assignment; an rvalue may appear only on the right-hand side.
- An lvalue may appear only on the left-hand side of an assignment; an rvalue may appear on either the left-hand or right-hand side.
- An lvalue and an rvalue may appear on either the left-hand or right-hand side of an assignment.
- An lvalue may appear on the left-hand or right-hand side of an assignment; an rvalue may appear only on the right-hand side.
Which operator is used to access the address of a variable?
س 44.-
%
-
**
-
*
-
&
Which add function properly returns the updated value of the result?
س 45.- :
void add (int a, int b, int *result)
{
*result = a+b;
}
main()
{
int a = 10;
int b = 20;
int result = 0;
add(a,b,&result);
}
- :
void add (int a, int b, int result)
{
result = a+b;
}
main()
{
int a = 10;
int b = 20;
int result = 0;
add(a,b,result);
}
- :
void add (int a, int b, int *result)
{
result = a+b;
}
main()
{
int a = 10;
int b = 20;
int result = 0;
add(a,b,result);
}
- :
void add (int *a, int *b, int *result)
{
result = a+b;
}
main()
{
int a = 10;
int b = 20;
int result = 0;
add(*a,*b,*result);
}
Consider the number of the Fibonacci series below 100: 0,1,1,2,3,5,8,13,21,34,55,89. Which piece of code outputs the sequence?
س 46.- :
void fibonacci(int a, int b)
{
int c = a+b;
if(a>100)
return;
printf("%d", a);
fibonacci(a,b);
}
int main()
{
fibonacci(0,1);
}
- :
void fibonacci(int a, int b)
{
int c = a+b;
if(a>100)
return;
printf("%d", b);
fibonacci(a,c);
}
int main()
{
fibonacci(0,1);
}
- :
void fibonacci(int a, int b)
{
int c = a+b;
if(a>100)
return;
printf("%d", a);
fibonacci(b,c);
}
int main()
{
fibonacci(0,1);
}
- :
void fibonacci(int a, int b)
{
int c = a+b;
if(a>100)
return;
printf("%d", c);
fibonacci(b,c);
}
int main()
{
fibonacci(0,1);
}
Which is ليس a storage class specifier?
Q47.-
intern
-
extern
-
register
-
static
Which line of code, after execution, results in i
having the value of 1?
س 48. -
for(i=1; i<=1; i++);
-
for(i=1; i=10; i++);
-
for(i=1; i==10; i++);
-
for(i=10; i>=1; i--);
What is the value of variable c at the end of this program?
Q49.1 main() {
2 int a, b, c;
3 a=10; b=50;
4 c=a * b % a;
5 }
- 50
- 5
- 0
- 500
one of the basic data types in C
س 50. ما هو ليس- long double
- unsigned char
- مجموعة مصفوفة
- float
What is the member access operator for a structure?
س 51.- ,
- []
- .
- :
What standard data type provides the smallest storage size and can be used in computations?
Q52.- char
- float
- int
- قصيرة
what does the ctype tolower() function do?
Q53.- It returns TRUE for lowercase letters of the alphabet.
- It ensures that text output uses only ASCII values (0 عبر 127).
- It returns FALSE for lowercase letters of the alphabet.
- It converts an uppercase letter of the alphabet to lowercase.
Void pointer vptr is assigned the address of float variable ز. What is a valid way to dereference vptr to assign its pointed value to a float variable named F later in the program?
س 54.float g;
void *vptr=&g;
-
f=(float *)vptr;
-
f=*(float *)vptr;
-
f=*(float)vptr;
-
f=(float)*vptr;
The dynamic memory allocation functions are defined in which system header file?
Q55.- stdio.h
- stdlib.h
- limits.h
- stddef.h
A function is a set of _.
س 56.- الإعلانات
- statements
- المتغيرات
- شاء
How are static functions different from global functions?
Q57.- Static functions must be declared in advance of being defined.
- Static functions must be declared in a separate header file.
- Static functions always return the same value.
- Static functions can be accessed only in the file where they are declared.
Which code example creates the string “Hello Mars” in storage buffer hello
.
س 58. - :
char hello[25];
strcpy(hello, "Hello ");
strcpy(hello, "Mars");
- :
char hello[25];
char *p;
strcpy(hello, "Hello World");
p = hello;
p +=6;
strcpy(p, "Mars");
- :
char *hello;
strcpy(hello, "Hello World");
hello+=6;
strcpy(hello, "Mars");
- :
char hello[25];
strcpy(hello, "Hello World");
strcpy(*hello[6], "Mars");
If you use the fopen() function with the “ا” وضع, what happens if the named file doesn’t exist?
س 59.- The file is created and opened for reading.
- The file is created and opened for writing.
- The fopen() function returns a NULL indicating that the operation has failed.
- The file is created and opened for both writing and reading
What does this function return?
س 60.int fl(int a, int b) { return(a>b?a:b); }
- compiler error
- the smaller value of the two passed parameters
- runtime error
- the greater value of the two passed parameters
Which option is a valid function name?
س 61.- draw_star()
- 5مرات()
- upper-limit()
- auto()
What is not a valid type definition of a structure that contains x and y coordinates as integers, and that can be used as shown for the variable named point?
س 62.coord point;
point.x = 9;
point.y = 3;
- :
struct coord{
int x;
int y;
};
typedef struct coord coord;
- :
typedef struct coord{
int x;
int y;
};
- :
typedef struct coord{
int x;
int y;
} coord;
- :
typedef struct{
int x;
int y;
} coord;
What is the output of the below program?
س 63.#include <stdio.h>
#if X == 3
#define Y 3
#else
#define Y 5
#endif
int main()
{
printf("%d", Y);
return 0;
}
- 3
- 5
- 3 أو 5 depending on input
- Compile time error
What do the functions malloc() and calloc() allocate?
س 64.- reallocated memory
- static memory
- dynamic memory
- fragmented memory
You need to determine if a string variable is a substring of another string. Which standard C library function do you use?
س 65.- substr(str1, str2);
- strstr(str1, str2);
- substring(str1, str2);
- strspn(str1, str2);
Find the output of the program.
س 66.#include <stdio.h>
#define L 10
int main(){
int a =10;
switch (a,a<<2){
case L:printf("a==L"); break;
case L*2 : printf("a = L* 2\n"); break;
case L*4 : printf("a = L* 4\n"); break;
default: printf("Error\n");
}
}
-
a=L*2
-
a=L
-
Error
-
a=L*4
Predict the output of the following code when the integer variables x is initialized to 10,y to 2, and z to 0.
Q67.z = x + y * x + 10 / 2 * x;
printf("value is =%d",z);
- 80
- 170
- 31.5
- 6
What will be the output of the following code snippet?
Q68.#include <stdio.h>
void solve() {
int x = 2;
printf("%d", (x << 1) + (x >> 1));
}
int main() {
solve();
return 0;
}
- 5
- 4
- 2
- 1
What is the output of this program?
Q69.int a=20, b=10;
int f1(a) {
return(a*b);
}
main() {
printf("%d", f1(5));
}
- 100
- 200
- 5
- 50
س 70. ما هو /0 حرف?
- String
- NULL Character
- ZERO
- عامل
What is the correct output for the following code?
س 71.#include<stdio.h>
#include<conio.h>
main()
{
int a=10, b=20;
clrscr();
printf("Before swapping a=%d b=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("nAfter swapping a=%d b=%d",a,b);
getch();
}
- Before a=10 b=20 , After a=10 b=10
- Before a=10 b=10 , After a=20 b=10
- Before a=10 b=20 , After a=20 b=20
- Before a=10 b=20 , After a=20 b=10
What is the Incorrect option that explains # pragma directive ?
التحكم في مخاطر سلامة العمليات.- #pragma exit allows us to specify functions called upon program exit.
- This is a preprocessor directive that can be used to turn on or off certain features.
- #pragma startup doesn’t allow us to specify functions called upon program startup.
- It is of two types #pragma startup, #pragma exit and pragma warn.
What will be the output of the following code snippet?
Q73.#include <stdio.h>
union School {
int age, rollNo;
double marks;
};
void solve() {
union School sc;
sc.age = 19;
sc.rollNo = 82;
sc.marks = 19.04;
printf("%d", (int)sizeof(sc));
}
int main() {
solve();
return 0;
}
- 2
- 4
- 8
- 10
What will be the output of the following code snippet?
التحكم في مخاطر سلامة العمليات.#include <stdio.h>
struct School {
int age, rollNo;
};
void solve() {
struct School sc;
sc.age = 19;
sc.rollNo = 82;
printf("%d %d", sc.age, sc.rollNo);
}
int main() {
solve();
return 0;
}
- 19 82
- Compilation Error
- 82 19
- None of these
What is the output of the following code snippet?
Q75.int main() {
int sum = 2 + 4 / 2 + 6 * 2;
printf("%d", sum);
return 0;
}
- 2
- 15
- 16
- 18
What does the following declaration mean?
س 76.int (*ptr)[10];
- ptr is an array of pointers to 10 integers
- ptr is a pointer to an array of 10 integers
- ptr is an array of 10 integers
- ptr is a pointer to an array
What will be the output of the following code snippet?
Q77.#include <stdio.h>
void change(int,int);
int main()
{
int a=10,b=20;
change(a,b); //calling a function by passing the values of variables.
printf("Value of a is: %d",a);
printf("\n");
printf("Value of b is: %d",b);
return 0;
}
void change(int x,int y)
{
x=13;
y=17;
}
- 10,20
- 10,10
- 20,20
- 20,10
تتم محاذاة كل طبقة وهذه كلها في نفس الوقت: The function “يتغير” will change the value of x and y only within its own scope, so a and is unaffected.
Choose true or false. When a variable is created in C, a memory address is assigned to the variable.
Q78.- صحيح
- خاطئة
What does the following fragment of C-program print?
Q79.#include <stdio.h>
int main()
{
char c[] = "GATE2011";
char *p = c;
printf("%s", p + p[3] -p[1]);
return 0;
}
- GATE 2011
- E2011
- 2011
- 01
تتم محاذاة كل طبقة وهذه كلها في نفس الوقت: char c[ ] = “GATE2011”; since char *p =c it means p represents the base address of string “GATE2011” SO p[3] is ‘E’ and p[1] is ‘A’. Value of Sub expression p[3] – p[1] = ASCII value of ‘E’ – ASCII value of ‘A’ = 4. So the expression p + ص[3] – p[1] becomes ( ص + 4) و (p+4) represent to base address of string “2011” printf(“%s”, ص + ص[3] – p[1]) ; So it will print 2011
What is the output of the following code snippet?
س 80.int main() {
int a = 5, b = 6, c;
c = a++ + ++b;
printf("%d %d %d", a, b, c);
return 0;
}
- 5 6 11
- 6 7 12
- 5 6 12
- 6 6 12
What will be the output of the following C program segment?
س 81.char inchar = 'A';
switch (inchar)
{
case 'A' :
printf ("choice A \n") ;
case 'B' :
printf ("choice B ") ;
case 'C' :
case 'D' :
case 'E' :
default:
printf ("No Choice") ;
}
- No choice
- Choice A
- Choice A Choice B No choice
- Program gives no output as it is erroneous
String variable str1 has the value of “abc”, and string variable str2 has the value “xyz”. What are the values of str1 and str2 after this statement is executed?
س 82.strcpy(str1, str2);
- str1: “xyz” ; str2: “xyz”
- str1: “abc” ; str2: “xyz”
- str1: “xyz” ; str2: “abc”
- str1: “abc” ; str2: “abc”
Which is not one of the basic data types in C?
س 83.- مجموعة مصفوفة
- float
- long double
- unsigned char
You have written a function that you want to include as a member of structure a. How is such as structure member defined?
س 84.- :
struct a {
void *f1;
};
- :
struct a {
void (*f1)();
};
- :
struct a {
*(void *f1)();
};
- :
struct a {
void *f1();
};
You need to determine if a string variable is a substring of another string. Which standard C library function do you use?
Q85.- substr(str1, str2);
- strstr(str1, str2);
- substring(str1, str2);
- strspn(str1, str2);
How are static functions different from global functions?
س 86.- Static functions must be declared in advance of being defined.
- Static functions must be declared in a separate header file.
- Static functions always return the same value.
- Static functions can be accessed only in the file where they are declared.
What does this program display?
Q87.main(){
char *p = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i;
for (i=0;i<5;i++) *p++; *p++;
printf("%c",*p++);
}
- ك
- M
- H
- G
What is not a valid command with this declaration?
Q88.char *string[20] = { "one", "two", "three"};
-
printf("%c", string[1][2]);
-
printf("%s", string[1][2]);
-
printf("%s", string[1]);
-
printf(string[1]);
إضافة تعليق
يجب عليك تسجيل الدخول او التسجيل لتستطيع اضافه تعليق .