If I want to initialize the array like.
int a[5] = {0};
then it gives me all element 0.
but if i give int a[5] = {5};
then 5 0 0 0 0 is ans.
what will I do for all element 5 5 5 5 5 in a single
statement???

Answers were Sorted based on User's Feedback



If I want to initialize the array like. int a[5] = {0}; then it gives me all element 0. but if i ..

Answer / n

int a[5]={5,5,5,5,5};

Is This Answer Correct ?    27 Yes 1 No

If I want to initialize the array like. int a[5] = {0}; then it gives me all element 0. but if i ..

Answer / jahid

int a[5]={5,5,5,5,5}

Is This Answer Correct ?    8 Yes 1 No

If I want to initialize the array like. int a[5] = {0}; then it gives me all element 0. but if i ..

Answer / litan parida

int a[1000];
memset(&a,0,sizeof(a))

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

how to generate the length of a string without using len funtion?

4 Answers  


In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT

1 Answers   IBM,


How can a string be converted to a number?

0 Answers  


Which driver is a pure java driver

0 Answers   Vertex,


print the following using nested for loop. 5 4 3 2 1 1 2 3 4 3 2 1 1 2 1 2 1 1 2 3 4 3 2 1 1 2 3 4 5

7 Answers   IBM,


Why the below program throughs error during compilation? #include<stdio.h> #include<conio.h> enum { ZERO, ONE, TWO, }; main() { printf("%d",&TWO); getch(); }

2 Answers  


What do you mean by dynamic memory allocation in c? What functions are used?

0 Answers  


I came across some code that puts a (void) cast before each call to printf. Why?

0 Answers  


write a program to insert an element at the specified position in the given array in c language

5 Answers   Appin, IBM,


What is the difference b/w Structure & Class?

3 Answers  


Linked lists -- can you tell me how to check whether a linked list is circular?

0 Answers  


What does c in a circle mean?

0 Answers  


Categories