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

how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

0 Answers  


What does c mean before a date?

0 Answers  


What is an volatile variable?

15 Answers   HP,


write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]

7 Answers  


What is Full Form of C and Why We use C

23 Answers  






what is the difference between : func (int list[], ...) or func (int *list , ....) - what is the difference if list is an array and if also if list is a pointer

2 Answers  


What is an lvalue in c?

0 Answers  


Write a program to reverse a linked list in c.

0 Answers   DELL, HAL,


Write a c code segment using a for loop that calculates and prints the sum of the even integers from 2 to 30, inclusive?

4 Answers  


There are N egg baskets and the number of eggs in each basket is a known quantity. Two players take turns to remove these eggs from the baskets. On each turn, a player must remove at least one egg, and may remove any number of eggs provided they all belong to the same basket. The player picking the last egg(s) wins the game. If you are allowed to decide who is going to start first, what mathematical function would you use to decide so that you end up on the winning side? Upload a C program to demonstrate the behaviour of the game.

2 Answers  


Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58

0 Answers   Zoho,


What are the general description for loop statement and available loop types in c?

0 Answers  


Categories