GMT: Chủ Nhật, ngày 15  tháng 7, năm 2018 . .   
Đăng nhập tạm thời:  

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   
 C#     C++     Visual Basic     Visual Foxpro     C     Java     Pascal     Thiết Kế Web     ASP.NET     XML     CSS     PHP   

Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 08
What will be the output of the program? #include int main() { int x = 10, y = 20; if(!(!x) && x) printf("x = %d\n", x); else printf("y = %d\n", y); return 0; } A. y =20 B. x = 0 C. x = 10 D. x = 1.... What will be the output of the program? #include int main() { int i=4; switch(i) { default:....
Thời gian bắt đầu: Hôm nay lúc 17:56:45(Server time)
Số câu hỏi: 10.   Tổng điểm: 10
Thời gian làm bài: 20 phút.  Thời gian còn lại: 
Cỡ chữ câu hỏi:  Cỡ chữ đáp án:
1-
What will be the output of the program?
#include<stdio.h>
int main()
{
    int x = 10, y = 20;
    if(!(!x) && x)
        printf("x = %d\n", x);
    else
        printf("y = %d\n", y);
    return 0;
}
A-
y =20
B-
x = 0
C-
x = 10
D-
x = 1
2-
What will be the output of the program?
#include<stdio.h>
int main()
{
    int i=4;
    switch(i)
    {
        default:
           printf("This is default\n");
        case 1:
           printf("This is case 1\n");
           break;
        case 2:
           printf("This is case 2\n");
           break;
        case 3:
           printf("This is case 3\n");
    }
    return 0;
}
A-
This is default
This is case 1
B-
This is case 3
This is default
C-
This is case 1
This is case 3
D-
This is default
3-
What will be the output of the program?
#include<stdio.h>
int main()
{
    int i = 1;
    switch(i)
    {
        printf("Hello\n");
        case 1:
            printf("Hi\n");
            break;
        case 2:
            printf("\nBye\n");
            break;
    }
    return 0;
}
A-
Hello
Hi
B-
Hello
Bye
C-
Hi
D-
Bye
4-
What will be the output of the program?
#include<stdio.h>
int main()
{
    char j=1;
    while(j < 5)
    {
        printf("%d, ", j);
        j = j+1;
    }
    printf("\n");
    return 0;
}
A-
1 2 3 ... 127
B-
1 2 3 ... 255
C-
1 2 3 ... 127 128 0 1 2 3 ... infinite times
D-
1, 2, 3, 4
5-
What will be the output of the program?
#include<stdio.h>
int main()
{
    int x, y, z;
    x=y=z=1;
    z = ++x || ++y && ++z;
    printf("x=%d, y=%d, z=%d\n", x, y, z);
    return 0;
}
A-
x=2, y=1, z=1
B-
x=2, y=2, z=1
C-
x=2, y=2, z=2
D-
x=1, y=2, z=1
6-
Point out the error, if any in the for loop.
#include<stdio.h>
int main()
{
    int i=1;
    for(;;)
    {
        printf("%d\n", i++);
        if(i>10)
           break;
    }
    return 0;
}
A-
There should be a condition in the for loop
B-
The two semicolons should be dropped
C-
The for loop should be replaced with while loop.
D-
No error
7-
Point out the error, if any in the program.
#include<stdio.h>
int main()
{
    int a = 10;
    switch(a)
    {
    }
    printf("This is c program.");
	return 0;
}
A-
Error: No case statement specified
B-
Error: No default specified
C-
No Error
D-
Error: infinite loop occurs
8-
Point out the error, if any in the program.
#include<stdio.h>
int main()
{
    int i = 1;
    switch(i)
    {
        printf("This is c program.");
        case 1:
            printf("Case1");
            break;
        case 2:
            printf("Case2");
            break;
    }
return 0;
}
A-
Error: No default specified
B-
Error: Invalid printf statement after switch statement
C-
No Error and prints "Case1"
D-
None of above
9-
Point out the error, if any in the while loop.
#include<stdio.h>
int main()
{
    int i=1;
    while()
    {
        printf("%d\n", i++);
        if(i>10)
           break;
    }
    return 0;
}
A-
There should be a condition in the while loop
B-
There should be at least a semicolon in the while
C-
The while loop should be replaced with for loop.
D-
No error
10-
Which of the following errors would be reported by the compiler on compiling the program given below?
#include<stdio.h>
int main()
{
    int a = 5;
    switch(a)
    {
	case 1:
	printf("First");

	case 2:
	printf("Second");

	case 3 + 2:
	printf("Third");

	case 5:
	printf("Final");
	break;

    }
    return 0;
}
A-
There is no break statement in each case.
B-
Expression as in case 3 + 2 is not allowed.
C-
Duplicate case case 5:
D-
No error will be reported.
[ Thành Lãm - ST ]

Chia sẻ trên Facebook   Google Boomarks   Google Buzz    Xem: 740. Đăng: 12-09-2012.   
Support Link:
Thông tin trang Web. Online since: 2011.
Disclaimer of Liability and Endorsement:
free counters
VNEDU.ORG IS A NON-PROFIT WEBSITE! All contents throughout this website are from Internet and other sources and are posted by users, copyright belongs to its original author. VNEDU.ORG stores for educational purpose only. VNEDU.ORG resumes no responsibility and liability, make no promise, or guarantee for the accuracy or efficiency of any content. If you find any content that is in violation of copyright laws, please notify us and we will immediately remove them. Thank you for visiting VNEDU.ORG