OOP CPP Programming language Array by Nadir Nadeem: Part-4
Array in c/cpp(c++):
Array:
- Store more than one values in a single variable.
- Array index start from zero
Syntax:
Datatype variable[]; à int x[]
Datatype variable[size]; à int x[4];
2D Array:
Syntax:
Datatype variable[][]; à int x[][];
Datatype variable[size][size]; à int x[3][4];
Example:
int x[]={12,461,753,6};
x:
values |
12 |
461 |
753 |
6 |
index |
0 |
1 |
2 |
3 |
Example:
17,18,19,20,21,22,23,24,25 è with also while loop
26,27,28,29,30,31,32,33,34
Ass#35,36: print variable value in [] à for and while
x[0]= 12
x[1]=461
Array:
Syntax:
Datatype varisble[];
Datatype variable[size in int];
Datatype variable[]={v1,v2,v3…};
Int x[]={10,20,30,40};
X:
values |
10 |
20 |
30 |
40 |
Index |
0 |
1 |
2 |
3 |
Example:
Example:
Example:
Example with loop:
Example:
Example:
2D Array:
Syntax:
Datatype variable[size][size];
Datatype variable[size][size]={{},{},…};
Example:
Example: with loop
Example:
Ass#38: Sum of required values:
How many values you want to sum: = 4
Enter v1= 3
Enter v2 = 2
Enter v3 = 2
Enter v4 = 4
3,2,2,4 values have sum = 11
Ass#40: Calculate the average
How many values you want to calculate average: = 4
Enter v1= 3
Enter v2 = 3
Enter v3 = 3
Enter v4 = 3
The average of above values := 3
Tags:
- array
- arrays
- array-comparison
- array-initialization
- array-algorithms
- array-of-structs
- array-of-pointers
- arraylist
- array-multiplication
- array-declaration
- array-dimension
- array-assignment
- array-sorting
- array-manipulation
- array-traversal
- array-concatenation
- array-pointer-arithmetic
- array-size
- array-resize
- array-copy
- array-slice
- array-indexing
- array-searching
- array-insertion
- array-deletion
- array-rotation
- array-sum
- array-unique
- array-intersection
- array-union
- array-merge
- array-reverse
- array-stack
- array-queue
- array-list
- array-buffer
- array-pointers
- array-2d
- array-3d
- array-multidimensional
- cpp
- c++
- part 4
Related Posts
Leave a Reply
You need to login to write a comment!
Popular Posts
-
Khewra Mine Salt
28.12.2023 0 Comments -
Gus's Fried Chicken
27.12.2023 0 Comments -
Magic Spoon Cereal Review
28.10.2023 0 Comments -
free software download websites for pc
21.09.2023 0 Comments -
Egyptian Perfumery: Perfume History in Egypt
03.04.2024 0 Comments -
Perfume History: Perfume: Cologne: Scent: Fragrance
02.04.2024 0 Comments
Categories
- AUTO(11)
- HEALTH(83)
- TECH(10)
- SCIENCE(0)
- SOCIAL MEDIA (0)
- PRESS RELEASES(0)
- TESTIMONIALS (References)(6)
- BIO(1)
- SPORTS (9)
- EARNING ONLINE(0)
- ARCHITECTURE(1)
- IT(51)
- Accessories(3)
- News(15)
- Pet(13)
- Programming (5)
- Shopping (15)
- Visiting Place (13)
- Foods & Candies(8)
- Style and Fashion (3)
- Geography (1)
- Personalities(2)
Random Posts
Tags
- Column Count
- contemporary dance
- Cascading Wonder in the Neelum Valley
- Natural Wonder
- LSI keywords
- Personal Grooming
- loop iteration order
- programming languages
- digital marketing jobs
- Iceland's Geothermal Energy Utilization
- Circulation improvement
- Epsom salt for greener leaves
- Keep Bottom Rows
- Sculpted
- automatic