Question: Which of the following are valid? int array [ 2 0 ] ; printf ( % d , array [ 0 ] )

Which of the following are valid?
int array[20];
printf("%d
", array[0]);
printf("%d
", array[20]);
printf("%d
", array[-1]);
printf("%d
", array[10]);
What will be the output of this code?
printf("%c", getchar());
printf("%c", getchar());
user keyboard input is "ab
unknown
a
ab
ab ab
Which of the following are valid?
int v =1;
int *p;
p = &v;
*p =*p +1;
p =*p +1;
*p = p +1;
v =*p +1;
Which of the following correctly declares an
array of 5 strings?
char strings[5][100];
char *strings[5];
char *strings = malloc(5);
char **strings = malloc(5*sizeof(char));
char **strings = malloc(5*sizeof(char*));
Which of the following are valid?
int v; char c;
scanf("%d", v);
scanf("%c", &c);
scanf("%c", &v);
scanf("%d", &c);
Which of the following are valid?
int v; char c;
scanf("%d", v);
scanf("%c", &c);
scanf("%c", &v);
scanf("%d", &c);
Consider the following code, what will be
printed?
int array[]={1,0,1};
int sum =0, i=0;
for (;i<=3;i++){
sum += array[i];
}
printf(%d, sum);
unknown because sum was never initialised
3
2
unknown; index out of array bounds
Consider the following code, what will be
printed?
int array[]={1,0,1};
int sum =0, i=0;
for (;i<=3;i++){
sum += array[i];
}
printf(%d, sum);
unknown because sum was never initialised
3
2
unknown; index out of array bounds
Which of the following will allow you to open
a file for reading?
FILE *f;
f = fopen(filename,w);
f = fopen(filename,a);
f = fopen(filename,r);
f = fopen(filename,rb);
Which of the following will allow you to open
a file for reading?
FILE *f;
f = fopen(filename,w);
f = fopen(filename,a);
f = fopen(filename,r);
f = fopen(filename,rb);
How many times does the following code
print Hello?
int i=0;
for (; i<10;)
printf(Hello);
i++;
10
9
1
infinity
How many times does the following code
print Hello?
int i=0;
for (; i<10;i++);{
printf(Hello);
}
10
9
1
infinity
What will i be after the following code?
int i =5;
i = i<<2;
1
false
0
20
What will i be after the following code?
int i =5;
i = i>>2;
1
false
0
20
What will i be after the following code?
int i =5;
i = i>>2;
1
false
0
20
What will b be after the following code?
int a=5, b=0;
if ((a=b)||(a==0)||(b=11)){
b++;
}
1
12
6
0
What will b be after the following code?
int a=5, b=0;
if ((a=b)||(a==0)||(b=11)){
b++;
}
1
12
6
0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!