New programmers are usually in the search of ways to return multiple values from a function. Unfortunately, C and C++ do not allow this directly.… Read More
Tag Archives: C-Arrays
Prerequisite – Array Basics Given an array, write a program to find the sum of values of even and odd index positions separately. Examples: Input :… Read More
In C, array name represents address and when we pass an array, we actually pass address and the parameter receiving function always accepts them as… Read More
Given two arrays such that first array has enough extra space to accommodate elements of second array. How to concatenate second array to first in… Read More
An array in C is a fixed-size homogeneous collection of elements stored at a contiguous memory location. It is a derived data type in C… Read More
#include <stdio.h> int main() { char p; char buf[10] = {1, 2, 3, 4, 5, 6, 9, 8}; p = (buf + 1)[5]; printf("%d\n", p);… Read More
#include<stdio.h> int main() { int a[10][20][30] = {0}; a[5][2][1] = 2; return 0; } Which of the following will print the value 2 for the… Read More
#include <stdio.h> int main() { int a[][] = {{1,2},{3,4}}; int i, j; for (i = 0; i < 2; i++) for (j = 0;… Read More
Does C perform array out of bound checking? What is the output of the following program? C int main() { int i; int arr[5] =… Read More
Predict output of following program int main() { int i; int arr[5] = {1}; for (i = 0; i < 5; i++) printf("%d ", arr[i]);… Read More
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… Read More
Which of the following is true about arrays in C. (A) For every type T, there can be an array of T. (B) For every… Read More
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… Read More
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… Read More
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. C void xyz(int… Read More