Section mcq’s choice Choice Choice 1,2 Choice 1,3,5


Download 63.22 Kb.
bet3/8
Sana03.06.2024
Hajmi63.22 Kb.
#1840512
1   2   3   4   5   6   7   8
Bog'liq
CODER EXAM

Response 2 – 5,5,5,5,1,1

  1. Can you write a code in C++ that removes all the whitespace from a given string? Write the program using classes and comment on each part of the code.

Response 1 – 5,5,5,5,1,1
Response 2 – 5,5,5,2,1,1


  1. How do I use the requests package in Python to hit an endpoint and retry if there are failures?

Response 1 – 3,4,4,4,1,1
Response 2 – 2,4,1,3,11


  1. How can I filter a list of coordinates using Python list comprehension?

Response 1 – 5,5,5,5,1,1
Response 2 – 2,4,5,2,1,1


  1. Try to optimize the following code:

const addIf: { [key: number]: string } = {
3: "Fizz",
5: "Buzz",
15: "FizzBuzz",
};

function f(n: number): string[] | string {


if (n <= 0) {
return "n value has to be more than 0";
}

return Array.from({ length: n }, (_, i) =>


Object.keys(addIf)
.map((d) => (i + 1) % Number(d) === 0 ? addIf[Number(d)] : ""))
.join('') || String(i + 1)
);
}

const n = 20; // Change this to the desired value of n


console.log(f(n));
Response 1 – 5,5,5,5,1,1
Response 2 – 4,4,2,2,1,1

  1. Create a Bash script that allows the reading of the content of a .txt file and print each line.

Response 1 – 3,2,3,4,1,1
Response 2 – 5,5,5,5,1,1


  1. Refactor this c code snippet, don't use bool, and keep cls

#include
#include
#define MAX 100

void remove(char list[MAX][21], int *p); // I'm ASSUMING search is a function defined elsewhere


printf("Which name do you want to remove? (input a number): ");

int del_id, i;

scanf("%d", &del_id);

if (del_id >= 0 && del_id < *p) {


for (i = del_id + 1; i < *p; i++) {
strcpy(list[i - 1], list[i]);
}
printf("Removed!\n");
(*p)--;
} else {
printf("Unremoved!\n");
}

system("cls");


}

Download 63.22 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling