Search Header Logo

CS 341 Lab 1 Spring 2024

Authored by CS241 Admin

Computers

University

Used 124+ times

CS 341 Lab 1 Spring 2024
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following does not depend on the architecture of the computer?

sizeof(char*)

sizeof(char)

sizeof(int)

sizeof(int*)

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a system call?

printf

fprintf

write

scanf

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which of the following is NOT true about malloc?

The memory allocated by malloc is not initialized.

Malloc will always allocate a block of memory.

Malloc may return NULL if the requested block size is 0.

The pointer returned by malloc is of type void*.

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

How do you allocate sufficient space on the heap to copy an existing string pointed to by a char pointer char* src?

malloc(sizeof(src) + 1)

malloc(sizeof(src))

malloc(strlen(src) + 1)

malloc(strlen(src))

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following code snippet? (Assume that an int is 4 bytes)


char* ptr = "123456789\0";

int *int_ptr = (int*)ptr;

printf("%s", int_ptr + 1);

56789

23456789

Segmentation Fault

123456789

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

int* ptr1, ptr2;


What are the data types of ptr1 and ptr2 if the above line is executed?

int*, int*

int, int

int*, int

int, int*

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the value of y in the following code?


int x;

int y = x + 2;

2

Undefined

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Microsoft

Continue with Microsoft

or continue with

Facebook

Facebook

Apple

Apple

Others

Others

Already have an account?