Qualcomm Array Quiz-1

Question 1

Time: 00:00:00
What will be the output of the program?


#include

int main()
{
void fun(int, int[]);
int arr[] = {1, 2, 3, 4};
int i;
fun(4, arr);
for(i=0; i<4; i++)
printf("%d,", arr[i]);
return 0;
}
void fun(int n, int arr[])
{
int *p=0;
int i=0;
while(i++ < n)
p = &arr[i];
*p=0;
}

2, 3, 4, 5

2, 3, 4, 5

1, 2, 3, 4

1, 2, 3, 4

0, 1, 2, 3

0, 1, 2, 3

3, 2, 1 0

3, 2, 1 0

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
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);
}

1

1

2

2

3

3

4

4

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
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;
}

0, 0, 0 1, 1, 1 2, 2, 2 3, 3, 3

0, 0, 0 1, 1, 1 2, 2, 2 3, 3, 3

1, 1, 2 2, 2, 3 3, 3, 4 4, 4, 1

1, 1, 2 2, 2, 3 3, 3, 4 4, 4, 1

1, 1, 1 2, 2, 2 3, 3, 3 3, 4, 4

1, 1, 1 2, 2, 2 3, 3, 3 3, 4, 4

0, 1, 2 1, 2, 3 2, 3, 4 3, 4, 5

0, 1, 2 1, 2, 3 2, 3, 4 3, 4, 5

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
What will be the output of the program?



#include

int main()
{
float arr[] = {12.4, 2.3, 4.5, 6.7};
printf("%d\n", sizeof(arr)/sizeof(arr[0]));
return 0;
}

5

5

4

4

6

6

7

7

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00

Which of the following statements are correct about the program below?


#include

int main()
{
int size, i;
scanf("%d", &size);
int arr[size];
for(i=1; i<=size; i++)
{
scanf("%d", arr[i]);
printf("%d", arr[i]);
}
return 0;
}

The code is erroneous since the subscript for an array used in for loop is in the range 1 to size.

The code is erroneous since the subscript for an array used in for loop is in the range 1 to size.

The code is erroneous since the values of the array are getting scanned through the loop.

The code is erroneous since the values of the array are getting scanned through the loop.

The code is erroneous since the statement declaring the array is invalid.

The code is erroneous since the statement declaring the array is invalid.

The code is correct and runs successfully

The code is correct and runs successfully

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Which of the following statements are correct about an array?


1: The array int num[26]; can store 26 elements.
2: The expression num[1] designates the very first element in the array.
3: It is necessary to initialize the array at the time of declaration.
4: The declaration num[SIZE] is allowed if SIZE is a macro.

1

1

1,4

1,4

2,3

2,3

2,4

2,4

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
Are the expressions arr and &arr same for an array of 10 integers?

yes

yes

no

no

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
myarr[5] is equivalent of?

&(myarr + 5)

&(myarr + 5)

*(myarr + 5)

*(myarr + 5)

(*myarr + 5)

(*myarr + 5)

None of the above

None of the above

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
Find the maximum sub-array sum for the following array:
{3, 6, 7, 9, 3, 8}

33

33

36

36

23

23

26

26

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
What is the value stored in sum[4] after the following program is executed?


#include
int max_num(int a,int b)
{
if(a> b)
return a;
return b;
}
int maximum_subarray_sum(int *arr, int len)
{
int sum[len], idx;
sum[0] = arr[0];
for(idx = 1; idx < len; idx++)
sum[idx] = max_num(sum[idx - 1] + arr[idx], arr[idx]);
int mx = sum[0];
for(idx = 0; idx < len; idx++)
if(sum[idx] > mx)
mx =sum[idx];
return mx;
}
int main()
{
int arr[] = {-2, 14, 11, -13, 10, -5, 11, -6, 3, -5},len = 10;
int ans = maximum_subarray_sum(arr, len);
printf("%d",ans);
return 0;
}

28

28

25

25

22

22

12

12

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice! \r\n","Keep trying! \r\n","Not bad! \r\n","Good work! \r\n","Perfect! \r\n"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/10

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects

Comments