Your SlideShare is downloading. ×
Arrays in c
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Arrays in c

279

Published on

Arrays in c

Arrays in c

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
279
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
41
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Arrays in c programming Typing Speed: muhammed ajmal ajmalmp777@gmail.com ajmalmp ajmalmp in.linkedin.com/in/profilena me 8547712876
  • 2. Arrays in c programming • An array is a collection of same type of elements which are sheltered under a common name.
  • 3. Different types of arrays • 1- dimensional array • 2-dimensional array • Multi-dimensional array
  • 4. One-dimensional arrays • One dimensional array have only one subscript under a common name. • syntax • Data_type array_name[array_size]; • Example • int age[5]={2,4,34,3,4};
  • 5. Example program • • • • • • • • • • • • • #include<stdio.h> int main() { int a[4]; int i; for ( i = 0; i < 4; i++ ) { Scanf(“%d”,&a[i]); } for ( i = 0; i < 4; i++ ) printf("a[%d] = %dn", i , a[i]); return 0; }
  • 6. Two-dimensional arrays • Two-dimensional array are those type of array, which has finite number of rows and finite number of columns. • Data_type Array_name [row size][column size];
  • 7. Example program • • • • • • • • • • • • • • • • • • • • • #include<stdio.h> int main() { int a[4][4], i , j; for (i = 0; i < 4; i++) { for ( j = 0; j < 4; j++) { a[i][j] = 0; scanf("a[%d][%d] ", i, j, a[i][j]); } } for (i = 0; i < 4; i++) { for ( j = 0; j < 4; j++) { a[i][j] = 0; printf("a[%d][%d] = %d n", i, j, a[i][j]); } } return 0; }
  • 8. Multi-dimensional arrays • An array have multiple subscript under a common name. • Syntax • type name[size1][size2]...[sizeN]; • Example • float a[2][6][7][4]….[n];
  • 9. • Subscripted Variable Rules • Subscripted variables can be double, integer, or character. • The maximum number of subscripts is dictated by the compiler vendor. Twelve is common. • Arithmetic expressions may be used for subscripts. • Subscripts must be integer valued. • A statement must be included in your program which sets aside storage space (dimensions) for your arrays.
  • 10. • • • • • • • • • • • • • • • • • • • • • • • • • • • Example programm #include<stdio.h> int main() { int a[4][4][4], i , j,k; for (i = 0; i < 4; i++) { for ( j = 0; j < 4; j++) { for ( k = 0; k < 4; k++) { a[i][j][k] = 0; scanf("a[%d][%d][%d] ", i, j,k, a[i][j][k]); } } } for (i = 0; i < 4; i++) { for ( j = 0; j < 4; j++) { for ( k = 0; k < 4; k++) { a[i][j][k] = 0; printf("a[%d][%d][%d] = %d n", i, j,k, a[i][j][k]); } } } • }
  • 11. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 12. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550

×