Explore topic-wise MCQs in Huawei.

This section includes 16 Mcqs, each offering curated multiple-choice questions to sharpen your Huawei knowledge and support exam preparation. Choose a topic below to get started.

1.

What will be the output of the program ? #include int main() { int arr[5], i=0; while(i<5) arr[i]=++i; for(i=0; i<5; i++) printf(“%d, “, arr[i]); return 0; }  

A. 1, 2, 3, 4, 5,
B. Garbage value, 1, 2, 3, 4,
C. 0, 1, 2, 3, 4,
D. 2, 3, 4, 5, 6,
Answer» C. 0, 1, 2, 3, 4,
2.

If the size of an integer is 4 bytes, What will be the output of the program ? #include #include int main() { printf(“%dn”, strlen(“123456”)); return 0; }  

A. 6
B. 12
C. 7
D. 2
Answer» B. 12
3.

What will be the output of the program? #include int main() { float f=43.20; printf(“%e, “, f); printf(“%f, “, f); printf(“%g”, f); return 0; }

A. 4.320000e+01, 43.200001, 43.2
B. 4.3, 43.22, 43.21
C. 4.3e, 43.20f, 43.00
D. Error
Answer» B. 4.3, 43.22, 43.21
4.

What will be the output of the program? #include int main() { float a=0.7; if(a < 0.7f) printf(“Cn”); else printf(“C++n”); return 0; }    

A. C
B. C++
C. Compiler error
D. Non of above
Answer» C. Compiler error
5.

What will be the output of the program? #include #include int main() { float n=1.54; printf(“%f, %fn”, ceil(n), floor(n)); return 0; }  

A. 2.000000, 1.000000
B. 1.500000, 1.500000
C. 1.550000, 2.000000
D. 1.000000, 2.000000
Answer» B. 1.500000, 1.500000
6.

What will be the output of the program? #include int main() { float d=2.25; printf(“%e,”, d); printf(“%f,”, d); printf(“%g,”, d); printf(“%lf”, d); return 0; }

A. 2.2, 2.50, 2.50, 2.5
B. 2.2e, 2.25f, 2.00, 2.25
C. 2.250000e+000, 2.250000, 2.25, 2.250000
D. error
Answer» D. error
7.

Point out the error in the program #include #define SI(p, n, r) float si; si=p*n*r/100; int main() { float p=2500, r=3.5; int n=3; SI(p, n, r); SI(1500, 2, 2.5); return 0; }  

A. 26250.00 7500.00
B. Nothing will print
C. Error: Multiple declaration of si
D. Garbage values
Answer» D. Garbage values
8.

Point out the error in the program #include int main() { int i; #if A printf(“Enter any number:”); scanf(“%d”, &i); #elif B printf(“The number is odd”); return 0; }

A. Error: unexpected end of file because there is no matching #endif
B. The number is odd
C. Garbage values
D. None of above
Answer» B. The number is odd
9.

What will be the output of the program ? #include #include int main() { char str1[20] = “Hello”, str2[20] = ” World”; printf(“%sn”, strcpy(str2, strcat(str1, str2))); return 0; }  

A. Hello
B. World
C. Hello World
D. WorldHello
Answer» D. WorldHello
10.

What will be the output of the program ? #include int main() { char p[] = “%dn”; p[1] = ‘c’; printf(p, 65); return 0; }  

A. A
B. a
C. c
D. 65
Answer» B. a
11.

What is the value of variable POLYGON? main ( ) { int POLYGON, L, B; L = B = 2; POLYGON = (L == B)? 1:0; }

A. 0
B. 1
C. 2
D. 0.5
Answer» C. 2
12.

What will be the value of the variable sum after the following program is executed? main ( ) { int sum, index; sum = 1 index = 9; do { index = index -1; sum = 2*sum; } while (index > 9);

A. 1
B. 2
C. 9
D. 0.5
Answer» C. 9
13.

Consider the following program fragment main ( ) {) int a,b,c; b = 2; a = 2*(b++); c = 2*(++b); } Which one of the given answers is correct?

A. a = 4, c = 6
B. a = 3, c = 8
C. a = 3, c = 6
D. a = 4, c = 8
Answer» E.
14.

Which of the following statements is true after execution of the program? int a[10],I,*p; a[0]=1; a[1]=2;p=a;(*p)++;

A. a[0] = 2
B. a[1] = 3
C. a[1] = 1
D. a[0] = 3
Answer» B. a[1] = 3
15.

Observe the following code and chose the right statement class Circle: public Shape { Point center; int radius; public: Circle(Point, int); // follow this line void draw(); void rotate(int) { } };

A. Circle(Point, int) is a default constructor in Circle Class
B. Circle(Point, int) is a user defined structure in Circle class
C. Circle(Point, int) is a method declaration in Circle class
D. Circle(Point, int) is a parameterized constructor
Answer» E.
16.

What is the output of the following program? #include using namespace std; class base { int val1, val2; public: int get() { val1 = 100; val2 = 300; } friend float mean (base ob); }; float mean (base ob) { return float (ob.val1 + ob.val2) / 2; } int main () { base obj; obj.get (); cout << mean (obj); return 0; }

A. 300
B. 150
C. 100
D. 200
Answer» E.