Tìm kiếm:
TRANG NHÀ
Giới thiệu VNEDU.ORG
Điều khoản và bản quyền
Liên lạc VNEDU
TRẮC NGHIỆM TRỰC TUYẾN
---Công Cụ:---
Soạn Biểu thức
Bảng màu HTML
Ký hiệu đặc biệt 01
Ký hiệu đặc biệt 02
Ký hiệu đặc biệt 03
Ký hiệu đặc biệt 04
Ký hiệu đặc biệt 05
Ký hiệu đặc biệt 06
Ký hiệu đặc biệt 07
Ký hiệu đặc biệt [Toán]
Tin Học   ||  Căn Bản    Văn Phòng    Hệ Thống - Mạng    Phần Mềm Ứng Dụng    Kỹ thuật số    Lập trình    SQL  

Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 57
Ngày làm bài: Hôm nay lúc 17:19:50 (Server time)
Số câu hỏi: 10.   Tổng điểm: 10
Yêu cầu hoàn thành: 60 phút.
Thời gian còn lại: 
Cỡ chữ câu hỏi:  Cỡ chữ đáp án:


1-
Assume integer is 2 bytes wide. How many bytes will be allocated for the following code?
#include<stdio.h>
#include<stdlib.h>
#define MAXROW 3
#define MAXCOL 4

int main()
{
    int (*p)[MAXCOL];
    p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p));
    return 0;
}

  A - 
56 bytes
  B - 
128 bytes
  C - 
24 bytes
  D - 
12 bytes
2-
Assume integer is 2 bytes wide. What will be the output of the following code?
#include<stdio.h>
#include<stdlib.h>
#define MAXROW 3
#define MAXCOL 4

int main()
{
    int (*p)[MAXCOL];
    p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p));
    printf("%d, %d\n", sizeof(p), sizeof(*p));
    return 0;
}

  A - 
2, 8
  B - 
4, 16
  C - 
8, 24
  D - 
16, 32
3-
How many bytes of memory will the following code reserve?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int *p;
    p = (int *)malloc(256 * 256);
    if(p == NULL)
        printf("Allocation failed");
    return 0;
}

  A - 
65536
  B - 
Allocation failed
  C - 
Error
  D - 
No output
4-
Point out the error in the following program.
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int *a[3];
    a = (int*) malloc(sizeof(int)*3);
    free(a);
    return 0;
}

  A - 
Error: unable to allocate memory
  B - 
Error: We cannot store address of allocated memory in a
  C - 
Error: unable to free memory
  D - 
No error
5-
Point out the error in the following program.
#include<stdio.h>
#include<stdlib.h>

int main()
{
    char *ptr;
    *ptr = (char)malloc(30);
    strcpy(ptr, "RAM");
    printf("%s", ptr);
    free(ptr);
    return 0;
}

  A - 
Error: in strcpy() statement.
  B - 
Error: in *ptr = (char)malloc(30);
  C - 
Error: in free(ptr);
  D - 
No error
6-
Point out the correct statement will let you access the elements of the array using 'p' in the following program?
#include
#include

int main()
{
    int i, j;
    int(*p)[3];
    p = (int(*)[3])malloc(3*sizeof(*p));
    return 0;
}

  A - 
for(i=0; i<3; i++)
{
    for(j=0; j<3; j++)
        printf("%d", p[i+j]);
}
  B - 
for(i=0; i<3; i++)
    printf("%d", p[i]);
  C - 
for(i=0; i<3; i++)
{
    for(j=0; j<3; j++)
        printf("%d", p[i][j]);
}
  D - 
for(j=0; j<3; j++)
    printf("%d", p[i][j]);
7-
Which of the following statement is correct prototype of the malloc() function in c ?
  A - 
int* malloc(int);
  B - 
char* malloc(char);
  C - 
unsigned int* malloc(unsigned int);
  D - 
void* malloc(size_t);
8-
Point out the correct statement which correctly free the memory pointed to by 's' and 'p' in the following program?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    struct ex
    {
        int i;
        float j;
        char *s
    };
    struct ex *p;
    p = (struct ex *)malloc(sizeof(struct ex));
    p->s = (char*)malloc(20);
    return 0;
}

  A - 
free(p); , free(p->s);
  B - 
free(p->s); , free(p);
  C - 
free(p->s);
  D - 
free(p);
9-
Point out the correct statement which correctly allocates memory dynamically for 2D array following program?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int *p, i, j;
    /* Add statement here */
    for(i=0; i<3; i++)
    {
        for(j=0; j<4; j++)
        {
            p[i*4+j] = i;
            printf("%d", p[i*4+j]);
        }
    }
    return 0;
}

  A - 
p = (int*) malloc(3, 4);
  B - 
p = (int*) malloc(3*sizeof(int));
  C - 
p = malloc(3*4*sizeof(int));
  D - 
p = (int*) malloc(3*4*sizeof(int));
10-
malloc() returns a float pointer if memory is allocated for storing float's and a double pointer if memory is allocated for storing double's.
  A - 
True
  B - 
False
 
[Người đăng: Thành Lãm - ST]
Ghé thăm Kênh của Vị Sư "hai lần chết đi sống lại"
Tu Si Chau Soc Thon

https://www.youtube.com/channel/UCoyC9WTTVR-M3qpTKKEXGnQ

Chau Soc Thon Official Channel


Phong Bảo Official
Phong Bao Official
Xem Nhiều nhất
Trắc Nghiệm Pascal - Bài 20
Trắc Nghiệm ASP.NET - Bài 12
Trắc Nghiệm Ngôn Ngữ Lập Trình C - Bài 16
Trắc Nghiệm ASP.NET - Bài 01
Trắc Nghiệm ASP.NET - Bài 03
Trắc nghiệm C++ - Bài 18
Trắc Nghiệm C# - Bài 53
Trắc Nghiệm ASP.NET - Bài 02
Trắc Nghiệm C# - Bài 42
Trắc Nghiệm Java - Bài 01
Trắc Nghiệm ASP.NET - Bài 04
Trắc Nghiệm Pascal - Bài 22
Trắc Nghiệm ASP.NET - Bài 13
Trắc Nghiệm ASP.NET - Bài 09
Trắc Nghiệm ASP.NET - Bài 08
Trắc nghiệm PHP - Bài 01
Trắc Nghiệm ASP.NET - Bài 06
Trắc Nghiệm ASP.NET - Bài 11
Trắc Nghiệm ASP.NET - Bài 05
Trắc Nghiệm ASP.NET - Bài 23
Đề Xuất
Trắc Nghiệm Java - Bài 54
Trắc Nghiệm Thiết Kế Web (English) - Bài 47
Trắc Nghiệm Java - Bài 25
Trắc Nghiệm C# - Bài 37
Trắc Nghiệm Visual Basic - Bài 11
Trắc Nghiệm ASP.NET (English) - Bài 13
Trắc Nghiệm Java - Bài 14
Trắc Nghiệm Visual Basic - Bài 33
Trắc Nghiệm ASP.NET (English) - Bài 10
Trắc Nghiệm C Sharp - Bài 09
Trắc Nghiệm Thiết Kế Web - Bài 13
Trắc nghiệm Ngôn Ngữ Lập Trình C++ - Bài 16
Trắc Nghiệm Java - Bài 21
Trắc Nghiệm Thiết Kế Web Và Flash - Bài 30
Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 38
Trắc Nghiệm Pascal - Bài 32
Trắc nghiệm Linux ( English ) - Bài 27
Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 12
Trắc Nghiệm Java - Bài 13
Trắc nghiệm XML - Bài 23
Phát triển hệ thống: TRƯƠNG HỮU ĐỨC - Phiên bản 3.0 - © Copyright 2013 - 2024 - VNEDU.ORG

free counters