C Programming - Typedef - Discussion
Discussion Forum : Typedef - Find Output of Program (Q.No. 2)
2.
What will be the output of the program?
#include<stdio.h>
int main()
{
typedef int arr[5];
arr iarr = {1, 2, 3, 4, 5};
int i;
for(i=0; i<4; i++)
printf("%d,", iarr[i]);
return 0;
}
Discussion:
20 comments Page 2 of 2.
Mithi said:
1 decade ago
@Abc.
'iarr' is the array and 'i' is its index.
'iarr' is the array and 'i' is its index.
ABC said:
1 decade ago
What does iarr[i] means?
Sathya said:
1 decade ago
Here "arr" is alias to "int" in first line.
Declaration of an array is int iarr[5] = {1, 2, 3, 4, 5};.
But here arr is alias to int so arr iarr[5] = {1, 2, 3, 4, 5};.
Declaration of an array is int iarr[5] = {1, 2, 3, 4, 5};.
But here arr is alias to int so arr iarr[5] = {1, 2, 3, 4, 5};.
Cherry said:
1 decade ago
typedef is used to create new data type. But it is commonly used to change existing data type with another name.
Jayadev( dilu ) said:
1 decade ago
Typedef names can be used to improve code readability.
You can declare any type with typedef, including pointer, function, and array types. You can declare a typedef name for a pointer to a structure or union type before you define the structure or union type, as long as the definition has the same visibility as the declaration.
You can declare any type with typedef, including pointer, function, and array types. You can declare a typedef name for a pointer to a structure or union type before you define the structure or union type, as long as the definition has the same visibility as the declaration.
Jayadev (dilu) said:
1 decade ago
Typedef used for reduce strucure component into single meaningful word.
Meena said:
1 decade ago
Give me some information about typedef.
Rookie said:
1 decade ago
Because the for loop is from 0.3 that's why only four elements are displayed.
Manisha said:
1 decade ago
Yes it is possible, because there is no multiply * symbol.
Sarada said:
1 decade ago
How come it possible? please reply.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers