Font size
WorksheetsArray and String
Total questions: 10
Worksheet time: 6mins
Defining arrays:
int c[ ];
int c;
int c[20];
Identify the error
(a)
Given :
int array[5]={1,4,8,5,6};
What is the output for:
array[2]
1
4
8
5
Given :
int array[5]={1,4,8,5,6};
What is the output for:
array[2+1]
1
4
8
5
Given :
int array[5]={1,4,8,5,6};
What is the output for:
array[2]+2
6
10
7
6
An array can store many different types of value.
True
False
Find the error:
#define SIZE 10;
(a)
Write a single statement to accomplish the following:
Copy the string stored in array s2 into array s1.
strcpy(s1,s2);
strncpy(s1,s2);
strcpy(s2,s1);
strncpy(s2,s1);
Functions that can be used to read the characters entered by user.
printf()
scanf()
getchar()
puts()
assume:
s1[20]="Happy ";
s2[20]="New Year";
which string-manipulation functions can be used to appends string s2 to s1?
strncat(s1,s2);
strcat(s1,s2);
strcpy(s1.s2);
strncpy(s1,s2);
