0% found this document useful (0 votes)
20 views3 pages

Assignment4Ch4ArrayandStringpdf 2024 09-30-13!16!17

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

Assignment4Ch4ArrayandStringpdf 2024 09-30-13!16!17

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Branch: Computer Engineering (AI, ML & DS)

Subject Name: Computer Programming


Subject Code: 01CE1101
Sem: B.Tech Sem - 1

Assignment 4
(Chapter – 4: Array and String)

1. State whether the following statements are True or False. (R)

a. If statement represents the evaluated result in the form of either non-zero


or zero values.

b. Nested if statement is not allowed in C.

c. In switch statement, the default case is optional.

d. In switch statement, two cases can have the same option.

e. In switch statement, each case should be enclosed by a parenthesis.

f. In switch statement, cases and default clause may occur in any order.

g. Body of the do..while statement is executed at least once.

h. While statement executes its body only if the condition is false.

i. The continue statement cannot be used with switch statement.

j. The strlen (s) function returns the length of the string s.

k. strcpy (s1, s2) function copies s2 to s1.

l. stract (s1, s2) concatenates s2 at the end of s1.

2. Choose most appropriate or correct answer from given options. (U/A/E)

a. What are the different ways to initialize an array with all elements as zero?

i. int array[5] = {};


ii. int array[5] = {0};
iii. int a = 0, b = 0, c = 0;
int array[5] = {a, b, c};
iv. All of the mentioned

b. What will be output of the following C code where we copy an array ‘a’ into
array ‘b’ and then the array ‘b’ into ‘a’?

#include<stdio.h>

R – Remembering, U – Understanding, A – Application, E – Evaluation, C – Create


Branch: Computer Engineering (AI, ML & DS)
Subject Name: Computer Programming
Subject Code: 01CE1101
Sem: B.Tech Sem - 1

#include<string.h>

void main ()

char a[] = "hell";

char b[] = "hello";

strcpy(b, a);

strcpy(a, b);

printf("%s, %s", a, b);

i. hello, hello

ii. hell, hell

iii. hell, hello

iv. Runtime Error

c. An array in C cannot be initialized by which of the following statement?

i. char a[] = “Hello”;

ii. char a[6] = {};

iii. char a[6] = {0};

iv. char a[6];

a = "Hello";

d. Array index start at

i. 1

ii. User Defined

iii. 0

iv. None of above

e. Which header file is necessary for strlen() function?

R – Remembering, U – Understanding, A – Application, E – Evaluation, C – Create


Branch: Computer Engineering (AI, ML & DS)
Subject Name: Computer Programming
Subject Code: 01CE1101
Sem: B.Tech Sem - 1

i. conio.h

ii. strings.h

iii. string.h

iv. stdio.h

f. How do you initialize an array in C?

i. int arr[3] = (1,2,3);

ii. int arr(3) = {1,2,3};

iii. int arr[3] = {1,2,3};

iv. int arr(3) = (1,2,3);

g. Assuming int is of 4bytes, what is the size of int arr[15];?

i. 30

ii. 15

iii. 4

iv. 60

3. What is an array? Explain with Example. What are the advantages of using an
array? [U]

4. WAP to reverse an array element in an array. [A]

5. WAP to find largest element in an array. [A]

6. Explain initialization and working of single and multi-dimensional array with


example. [U]

7. WAP input a m×n matrix and display its transpose. [A]

8. WAP input two m×n matrix and multiply it. [A]

9. Explain 5 string handling functions available in ‘C’ with example. [C]

10. WAP input a string and check whether the inputted string is palindrome or not.
[A]

R – Remembering, U – Understanding, A – Application, E – Evaluation, C – Create

You might also like