LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C Programming
  • Arrays

C Programming

ARRAYS MCQs

Total Questions : 15

Page 1 of 2 pages
Question 1.

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


  1.    Yes
  2.    No
 Discuss Question
Answer is Option B. -> No

Both mean two different things. arr gives the address of the first int, whereas the &arr gives

 the address of array of ints.

Question 2.

Is there any difference int the following declarations?
int fun(int arr[]);
int fun(int arr[2]);


  1.    Yes
  2.    No
 Discuss Question
Answer is Option B. -> No

No, both the statements are same. It is the prototype for the function fun() that accepts 

one integer array as an parameter and returns an integer value.

Question 3.

Does this mentioning array name gives the base address in all the contexts?


  1.    Yes
  2.    No
 Discuss Question
Answer is Option B. -> No

No, Mentioning the array name in C or C++ gives the base address in all contexts except one.

Syntactically, the compiler treats the array name as a pointer to the first element. You can 

reference elements using array syntax, a[n], or using pointer syntax, *(a+n), and you can 

even mix the usages within an expression.

When you pass an array name as a function argument, you are passing the "value of the 

pointer", which means that you are implicitly passing the array by reference, even though 

all parameters in functions are "call by value".

Question 4.

A pointer to a block of memory is effectively same as an array


  1.    True
  2.    False
 Discuss Question
Answer is Option A. -> True

Yes, It is possible to allocate a block of memory (of arbitrary size) at run-time, using 

the standard library's malloc function, and treat it as an array.

Question 5.

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
  2.    1,4
  3.    2,3
  4.    2,4
 Discuss Question
Answer is Option B. -> 1,4

1. The array int num[26]; can store 26 elements. This statement is true.

2. The expression num[1] designates the very first element in the array. This statement is

 false, because it designates the second element of the array.

3. It is necessary to initialize the array at the time of declaration. This statement is false.

4. The declaration num[SIZE] is allowed if SIZE is a macro. This statement is true, because

 the MACRO just replaces the symbol SIZE with given value.

Hence the statements '1' and '4' are correct statements.


Question 6.

Which of the following statements are correct about 6 used in the program?
int num[6];
num[6]=21;


  1.    In the first statement 6 specifies a particular element, whereas in the second statement it specifies a type.
  2.    In the first statement 6 specifies a particular element, whereas in the second statement it specifies a type.
  3.    In the first statement 6 specifies a particular element, whereas in the second statement it specifies a array size.
  4.    In both the statement 6 specifies array size.
 Discuss Question
Answer is Option B. -> In the first statement 6 specifies a particular element, whereas in the second statement it specifies a type.

The statement 'B' is correct, because int num[6]; specifies the size of array and num[6]=21;

designates the particular element(7th element) of the array.

Question 7.


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



#include<stdio.h>

int main()
{
int size, i;
scanf("%d", &size);
int arr[size];
for(i=1; i
  1.    The code is erroneous since the subscript for array used in for loop is in the range 1 to size.
  2.    The code is erroneous since the values of array are getting scanned through the loop.
  3.    The code is erroneous since the statement declaring array is invalid.
  4.    The code is correct and runs successfully.
 Discuss Question
Answer is Option C. -> The code is erroneous since the statement declaring array is invalid.

The statement int arr[size]; produces an error, because we cannot initialize the

 size of array dynamically. Constant expression is required here.

Example: int arr[10];

One more point is there, that is, usually declaration is not allowed after calling

 any function in a current block of code. In the given program the declaration

 int arr[10]; is placed after a function call scanf().

Question 8.


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


#include<stdio.h>

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])
{
}


  1.    A
  2.    A, B
  3.    B
  4.    B, D
 Discuss Question
Answer is Option B. -> A, B

Answer:  (A)

void fun(int p[][4]){ } is the correct way to write the function fun(). while the others are considered only the function fun() is called by using call by reference.

Question 9.


What will be the output of the program if the array begins 1200 in memory?



#include<stdio.h>

int main()
{
int arr[]={2, 3, 4, 1, 6};
printf("%u, %u, %u\n", arr, &arr[0], &arr);
return 0;
}

  1.    1200, 1202, 1204
  2.    1200, 1200, 1200
  3.    1200, 1204, 1208
  4.    1200, 1202, 1200
 Discuss Question
Answer is Option B. -> 1200, 1200, 1200

Step 1: int arr[]={2, 3, 4, 1, 6}; The variable arr is declared as an integer array and initialized.

Step 2: printf("%u, %u, %un", arr, &arr[0], &arr); Here,

The base address of the array is 1200.

=> arr, &arr is pointing to the base address of the array arr.

=> &arr[0] is pointing to the address of the first element array arr. (ie. base address)

Hence the output of the program is 1200, 1200, 1200

Question 10.

Which of the following statements mentioning the name of the array begins DOES NOT yield

 the base address?

1: When array name is used with the sizeof operator.
2: When array name is operand of the & operator.
3: When array name is passed to scanf() function.
4: When array name is passed to printf() function.


  1.    A
  2.    A, B
  3.    B
  4.    B, D
 Discuss Question
Answer is Option B. -> A, B

The statement 1 and 2 does not yield the base address of the array. While the scanf() 

and printf() yields the base address of the array.

  • 1
  • 2
  • Next →
  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

  • Arrays
  • Bitwise Operators
  • C Preprocessor
  • Command Line Arguments
  • Complicated Declarations
  • Const
  • Control Instructions
  • Declarations And Initializations
  • Expressions
  • Floating Point Issues
  • Functions
  • Input / Output
  • Library Functions
  • Memory Allocation
  • Pointers
  • Strings
  • Structures
  • Subleties Of Typedef
  • Variable Number Of Arguments

Topics

  • Computer Aptitude
  • SAIL Junior Officer (E-0)
  • 10th Grade
  • 11th Grade
  • 12th Grade
  • 4th Grade
  • 5th Grade
  • 6th Grade
  • 7th Grade
  • 8th Grade
  • 9th Grade
  • NCERT
  • Cat
  • Commerce
  • Computer Science
  • Engineering
  • English
  • General Knowledge
  • Ias
  • Management
  • Quantitative Aptitude
  • Reasoning Aptitude
  • General Studies (Finance And Economics)
  • Analytical Instrumentation
  • Biochemistry
  • Bioinformatics
  • Biology
  • Biotechnology
  • Bitsat
  • Business Statistics
  • C Programming
  • C++ Programming
  • Cell Biology
  • Chemistry
  • Cost Accounting
  • Drug And Pharmaceutical Biotechnology
  • Electrical Measurement And Instrumentation
  • Environment Management
  • Environmental Biotechnology
  • Enzyme Technology
  • Financial Management And Financial Markets
  • Gate
  • General Science
  • Geography
  • Heat Transfer
  • History And National Movements
  • Human Anatomy And Physiology
  • Human And Cultural Diversity
  • Human Resource Management
  • Indian Economy
  • Indian Geography
  • Indian History
  • Indian Polity
  • Instrumentation Transducers
  • International Relations
  • Life Sciences
  • Marketing And Marketing Management
  • Mass Transfer
  • Mechanics Of Materials
  • Microbiology
  • Neet
  • Professional Communication
  • Renewable Energy
  • Sociology
  • Surveying
  • Total Quality Management
  • Uidai Aadhaar Supervisor Certification
  • Virology

Recent Questions

Q.   The Mortar In Which Both Cement And Lime Are Used As Binding....

Q.   In....

Q.   High Temperature In Gasification Of Coal Favours

Q.   The __________ Engines Can Work On Very Lean Mixture Of Fuel....

Q.   Ch....

Q.   Purification Of Blood Takes Place In

Q.   What Is The Minimum Vapour Pressure (in KPa) Of The Working ....

Q.   The Kaposi’s Sarcoma Is Caused By ____________________

Q.   Neutral Atmosphere Is Maintained In A/an __________ Furnace.....

Q.   Raju Has 14 Currency Notes In His Pocket Consisting Of Only....

Q.   " You Are Thinking Very Highly About Ravi But He Is Not....

Q.   The Range Of Electromagnetic Spectrum Important In Heat Tran....

Q.   Th....

Q.   January : November : : Sunday : ?

Q.   Consider The Following Statements.There Are 25 High Courts I....

Q.   T....

Q.   In Which Type Of Sedimentation, The Flocculent Suspension Of....

Q.   Hardening Of Metal Is Due To Heating To A Particular Temper....

Q.   Which Of The Following Materials Has The Highest Electrical ....

Q.   ....

LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • YouTube Channel
  • Maths Fast Trick
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password