More options
Forms of functionPointer
File handling
function
Syntax :Example: int marks[30];datatype arrayname[size]
- Array declaration-
Here int : specifies the type of variable. marks : specifies name of variable(i.e array). 30 : specifies how many elements of the types int will be in array it is also known as diamension. [ ] : bracket tells the compiler that we are dealing with an array.Array initialization-(at the time of declaration)
Example : int num[6]={ 2,4,5,6,7,8}; int n[]={2,4,5,6,7,8}; float press[]={1.1, 1.2, 1.3, 5.6}; char name[4]={'a', 'b', 'f','\0'}; char name[5]="bca";
void main() { int rollno; char name[20]; char add[30]; clrscr(); printf("enter your rollno="); scanf("%d",&rollno); printf("Enter your name="); scanf("%s",name); printf("Enter address= "); scanf("%s",add); printf("roll no=%d\n",rollno); printf("\n NAME=%s"\n address=%s",name,add); getch(); }
[ 4 ] [ 2] matrix row column
column 0 column 1 row 0 [0] [0] [0] [1] row 1 [1] [0] [1] [1] row 2 [2] [0] [2] [1] row 3 [3] [0] [3] [1]
int stud[4][2]={ {11,60}, {34,56}, {45,50}, {114,75} }; Method 2- int stud[4][2]={11,60,34,56,45,50,114,75};
void main() { int a[2][2]; int i,j; clrscr(); printf("enter 4 elements for matrix"); for(i=0;i<2;i++) { for(j=0;j<2;j++) { printf("\n enter a[%d][%d]="i,j); scanf("%d"&a[i][j]); } } printf("\n matrix :\n"); for(i=0;i<2;i++) { for(j=0;j<2;j++) { printf("%d\t",a[i][j]); } printf("\n"); } getch(); } output : enter 4 elements for matrix enter a[0][0]=1 enter a[1][0]=2 enter a[1][0]=3 enter a[1][1]=4 matrix : 1 2 3 4