C Language - Arrays

You Are Here :: Home > C Language > Arrays - General Questions

 
25.

What will be the output of the program ?

#include
void fun(int **p);
int main()
{
int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0};
int *ptr;
ptr = &a[0][0];
fun(&ptr);
return 0;
}
void fun(int **p)
{
printf("%d\n", **p);
}

A. 1 B. 2
C. 3 D. 4




26.

What will be the output of the program ?

#include
int main()
{
static int arr[] = {0, 1, 2, 3, 4};
int *p[] = {arr, arr+1, arr+2, arr+3, arr+4};
int **ptr=p;
ptr++; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr);
*ptr++; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr);
*++ptr; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr);
++*ptr; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr);
return 0;
}

A. 0, 0, 0
1, 1, 1
2, 2, 2
3, 3, 3
B. 1, 1, 2
2, 2, 3
3, 3, 4
4, 4, 1
C. 1, 1, 1
2, 2, 2
3, 3, 3
3, 4, 4
D. 0, 1, 2
1, 2, 3
2, 3, 4
3, 4, 5




27.

Which of the following is correct way to define the function fun() in the below program?

#include
int main()
{
int a[3][4];
fun(a);
return 0;
}

A. void fun(int p[][4]) { } B. void fun(int *p[4]) { }
C. void fun(int *p[][4]) { } D. void fun(int *p[3][4]) { }




28.

What will be the output??

#include< stdio.h>
#include< conio.h>
void main()
{
int arr[] = { 51,32,43,24,5,26};
int i;
for(i=0;i<=5;i++)
printf("\n%d %d %d %d",arr[i],*(i+arr),*(arr+i),i[arr]);
getch();
}

A. 57 57 57 57
32 32 32 32
43 43 43 43
24 24 24 24
5 5 5 5
26 26 26 26
B. 57 57 57 57
32 33 33 33
43 43 43 43
24 24 24 24
26 26 26 26
C. 51 51 51 51
32 32 32 32
43 43 43 43
24 24 24 24
5 5 5 5
26 26 26 26
D. 51 51 51 51
32 32 32 32
43 43 43 43
24 24 24 24
26 26 26 26




29.

What will be the output of this program?

#include
using namespace std;
int array1[] = {1200, 200, 2300, 1230, 1543};
int array2[] = {12, 14, 16, 18, 20};
int temp, result = 0;
int main()
{
for (temp = 0; temp < 5; temp++) {
result += array1[temp];
}
for (temp = 0; temp < 4; temp++) {
result += array2[temp];
}
cout << result;
return 0;
}

A. 6553 B. 6533
C. 6522 D. 12200




30.

What will be the output of the this program?

#include
using namespace std;
int main ()
{
int array[] = {0, 2, 4, 6, 7, 5, 3};
int n, result = 0;
for (n = 0 ;n < 5 ;n++) {
result += billy[n];
}
cout << result;
return 0;
}

A. 25 B. 26
C. 27 D. None of the mentioned




« previous

1

2

3

4

5

6

7

8

9

...

next »

 
 
 



© 2013 freshersindia.in ® | Copyrights | Terms & Conditions
   Designed by Freshers India
Catch Us on