Write code for initializing one dimentional and two
dimentional array in a C Program?

Answers were Sorted based on User's Feedback



Write code for initializing one dimentional and two dimentional array in a C Program?..

Answer / raam_bangaloreallinter

1-D array:

int a[4]={ 10,20,30,40};

2-D array: # 2 columns and 2 rows
int a[2][2]= {
{100,200},
{300,400} };


Raam - ramumcato@yahoo.com

Is This Answer Correct ?    19 Yes 1 No

Write code for initializing one dimentional and two dimentional array in a C Program?..

Answer / shruti

Ans no. 4 is correct..

incase u have to initialise an array have more number of
elements as i 100 or 200..

eg..

int a[50];
then u can use following functions:

**YOU CAN INITIALISE IT TO A PARTICULAR VALUE ONLY USING
THE BELOW CODE..

int a[50];
int i;

for (i = 0 ; i < 50 ; i++)
{
a[i] = 0;
}

similarly for 2D

for(i = 0 ; i < 50 ; i++)
{
for(j = 0 ; j < 50 ; j++)
{
a[i][j] = 0;
}
}

Is This Answer Correct ?    11 Yes 3 No

Write code for initializing one dimentional and two dimentional array in a C Program?..

Answer / kalpana.y

array:array is a collection of elements
one dimensional array:
code:
datatype arraysize[];
eg:
int a[5];
two-dimensional array:
code:
datatype array[rowsize][columnsize];
eg:
int a[5][5];

Is This Answer Correct ?    14 Yes 8 No

Write code for initializing one dimentional and two dimentional array in a C Program?..

Answer / dinesh kumar

static int [5]={2,3,4,5,6};
for one dimensional array
static int[3][3]={1,2,3,4,5,6};
for two dimensional array it consider as rows and columns

Is This Answer Correct ?    7 Yes 12 No

Write code for initializing one dimentional and two dimentional array in a C Program?..

Answer / varsha vilas kalebag

one dimensional array :
a={2}
two dimensional array
b={2,3}

Is This Answer Correct ?    5 Yes 18 No

Post New Answer

More C Interview Questions

What is difference between structure and union?

0 Answers  


Function shall sum members of given one-dimensional array. However, it should sum only members whose number of ones in the binary representation is higher than defined threshold (e.g. if the threshold is 4, number 255 will be counted and 15 will not) - The array length is arbitrary - output the results to the stdout

0 Answers   XYZ,


What is getch () for?

0 Answers  


A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM

0 Answers   HCL,


write a program in c language to print your bio-data on the screen by using functions.

0 Answers  






What are different types of variables in c?

0 Answers  


What is malloc() function?

0 Answers  


what is the purpose of the code, and is there any problem with the code? int f( int n, int l, int r ) { return (n << l) >> r; }

2 Answers   Google,


wat is the difference between array and pointer?

4 Answers   Wipro,


Why does notstrcat(string, "!");Work?

0 Answers  


Tell me when is a void pointer used?

0 Answers  


to get a line of text and count the number of vowels in it

2 Answers  


Categories