[go: up one dir, main page]

0% found this document useful (0 votes)
25 views6 pages

Quiz About C Arrays

The document contains a series of programming questions related to C arrays, including predicting outputs of various C programs and understanding array behavior. Each question presents a code snippet and multiple-choice answers for users to select from. The document serves as a quiz or tutorial for individuals practicing their C programming skills.

Uploaded by

chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views6 pages

Quiz About C Arrays

The document contains a series of programming questions related to C arrays, including predicting outputs of various C programs and understanding array behavior. Each question presents a code snippet and multiple-choice answers for users to select from. The document serves as a quiz or tutorial for individuals practicing their C programming skills.

Uploaded by

chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Tutorials

Search... Sign In
Practice
Jobs
DSA Practice Problems C C++ Java Python JavaScript Data Science Machine Learning Courses Linux DevOps SQL Web Develop

C Arrays
Last Updated : Mar 19, 2024 Discuss

Question 1

Predict the output of below program:

#include <stdio.h>

int main()
{
int arr[5];

// Assume that base address of arr is 2000 and size of integer


// is 32 bit
arr++;
printf("%u", arr);

return 0;
}

A 2002

B 2004

C 2020

D invalid Operation with array address

Discuss it

Question 2

Predict the output of below program:

#include <stdio.h>

int main()
{
int arr[5];
// Assume base address of arr is 2000 and size of integer is 32 bit
printf("%u %u", arr + 1, &arr + 1);

return 0;
}

A 2004 2020

B 2004 2004

C 2004 Garbage value

D The program fails to compile because Address-of operator cannot be used with array name

Discuss it
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
Got It !
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Question 3

What is the output for a 64-bit Compiler?

# include <stdio.h>

void print(int arr[])


{
int n = sizeof(arr)/sizeof(arr[0]);
int i;
for (i = 0; i < n; i++)
printf("%d ", arr[i]);
}

int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};
print(arr);
return 0;
}

A 1, 2, 3, 4, 5, 6, 7, 8

B Compiler Error

C 12

D Run Time Error

Discuss it

Question 4

Output of following program?

#include<stdio.h>

int main()
{
int a[] = {1, 2, 3, 4, 5, 6};
int *ptr = (int*)(&a+1);
printf("%d ", *(ptr-1) );
return 0;
}

A 1

B 2

C 6

D Runtime Error

Discuss it

Question 5

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
Consider the following C-function in which a[n] and b[m] are two sorted integer arrays and c[n + m] be another integer array.
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
void xyz(int a[], int b [], int c[])
{
int i, j, k;
i = j = k = O;
while ((i < n) && (j < m))
if (a[i] < b[j]) c[k++] = a[i++];
else c[k++] = b[j++];
}

Which of the following condition(s) hold(s) after the termination of the while loop? (GATE CS 2006) (i) j < m, k = n+j-1, and a[n-1] < b[j] if i
= n (ii) i < n, k = m+i-1, and b[m-1] <= a[i] if j = m
A only (i)

B only (ii)

C either (i) or (ii) but not both

D neither (i) nor (ii)

Discuss it

Question 6

Assume the following C variable declaration

int *A [10], B[10][10];

Of the following expressions I A[2] II A[2][3] III B[1] IV B[2][3] which will not give compile-time errors if used as left hand sides
of assignment statements in a C program (GATE CS 2003)?

A I, II, and IV only

B II, III, and IV only

C II and IV only

D IV only

Discuss it

Question 7

Consider the following declaration of a ‘two-dimensional array in C:

char a[100][100];

Assuming that the main memory is byte-addressable and that the array is stored starting from memory address 0, the
address of a[40][50] is (GATE CS 2002)

A 4040

B 4050

C 5040
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
D 5050
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Discuss it

Question 8

Predict the output of the below program:

#include <stdio.h>
#define SIZE(arr) sizeof(arr) / sizeof(*arr);
void fun(int* arr, int n)
{
int i;
*arr += *(arr + n - 1) += 10;
}

void printArr(int* arr, int n)


{
int i;
for(i = 0; i < n; ++i)
printf("%d ", arr[i]);
}

int main()
{
int arr[] = {10, 20, 30};
int size = SIZE(arr);
fun(arr, size);
printArr(arr, size);
return 0;
}

A 20 30 40

B 20 20 40

C 50 20 40

D Compile-time error

Discuss it

Question 9

Predict output of following program

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

A 1 followed by four garbage values

B 10000

C 11111

D 00000
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Discuss it

Question 10

Does C perform array out of bound checking? What is the output of the following program?

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

A Compiler Error: Array index out of bound.

B The always prints 0 five times followed by garbage value

C The program always crashes.

D The program may print 0 five times followed by garbage value, or may crash if address (arr+5) is invalid.

Discuss it

Tags: C Quiz

There are 37 questions to complete.

Take a part in the ongoing discussion View All Discussion

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Company Explore Tutorials DSA Data Science & Web
About Us Job-A-Thon Python Data Structures ML Technologies
Corporate & Communications Legal Offline Java Algorithms Data Science With HTML
Address: Privacy Policy Classroom C++ DSA for Python CSS
Careers Program PHP Beginners
A-143, 7th Floor, Machine Learning JavaScript
Sovereign Corporate In Media DSA in GoLang Basic DSA ML Maths TypeScript
Tower, Sector- 136, Noida, Contact Us JAVA/C++ SQL Problems Data Visualisation ReactJS
Uttar Pradesh (201305) Corporate Master R Language DSA Roadmap Pandas NextJS
Solution System Android DSA Interview
Registered Address: NumPy NodeJs
Campus Design Questions
K 061, Tower K, Gulshan NLP Bootstrap
Training Master CP Competitive
Vivante Apartment, Sector Deep Learning Tailwind CSS
137, Noida, Gautam Buddh Program Videos Programming
Nagar, Uttar Pradesh,
201305 Python Computer DevOps System School Databases
Tutorial Science Git Design Subjects SQL

Python GATE CS AWS High Level Mathematics MYSQL

Examples Notes Docker Design Physics PostgreSQL


Django Operating Kubernetes Low Level Chemistry PL/SQL

Tutorial Systems Azure Design Biology MongoDB

Python Computer GCP UML Diagrams Social Science

Projects Network DevOps Interview Guide English Grammar


Advertise with us Python Database Roadmap Design Patterns
Tkinter Management OOAD
Web Scraping System System Design
OpenCV Software Bootcamp
Tutorial Engineering Interview
Python Digital Logic Questions
Interview Design

Question Engineering
Maths

Preparation More Courses Programming Clouds/Devops GATE 2026


IBM Languages DevOps GATE CS Rank
Corner Tutorials
Certification C Programming Engineering Booster
Company- Software
Courses with Data AWS Solutions GATE DA Rank
Wise Development
DSA and Structures Architect Booster
Recruitment Software
Placements C++ Certification GATE CS & IT
Process Testing
Web Programming Salesforce Course - 2026
Aptitude Product
Development Course Certified GATE DA
Preparation Management
Data Science Java Administrator Course 2026
Puzzles Project
Programming Programming Course GATE Rank
Company- Management
Languages Course Predictor
Wise Linux
DevOps & Python Full
Preparation Excel
Cloud Course
All Cheat
Sheets

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy

You might also like