DMCA.com Protection Status C Programming – Day 5 | Arrays in C (1D & 2D) Arrays Explained for Beginners - ZAREEN TECH WAVE -Largest Tutorials Website For Freelancer ZAREEN TECH WAVE -Largest Tutorials Website For Freelancer

Header Ads

C Programming – Day 5 | Arrays in C (1D & 2D) Arrays Explained for Beginners

ARRAYS IN C (1D & 2D)

DAY - 5




We’ll continue learning...........


📍 Day-5 — Arrays in C (1D & 2D)

Today you will learn:

✅ What is an array?
✅ Declaring and initializing arrays
✅ Input/Output using loop
✅ Finding largest number
✅ 2D array (matrix) basics
✅ Task + Quiz


✅ 1️⃣ What is an Array?

📌 An array stores multiple values of same data type in continuous memory.

Example:

int marks[5];

📌 Index starts from 0
So marks[0] → 1st element


✅ 2️⃣ Array Initialization

int nums[5] = {10, 20, 30, 40, 50};

✅ 3️⃣ Input & Print Array Using Loop

int arr[5]; for(int i=0; i<5; i++){ scanf("%d", &arr[i]); } for(int i=0; i<5; i++){ printf("%d ", arr[i]); }

✅ 4️⃣ Find Largest Element in Array

int arr[5] = {10, 25, 5, 45, 30}; int max = arr[0]; for(int i=1; i<5; i++){ if(arr[i] > max) max = arr[i]; } printf("Largest = %d", max);

✅ 5️⃣ 2D Array (Matrix)

int a[2][3] = { {1, 2, 3}, {4, 5, 6} };

Rows = 2
Columns = 3


🧪 Practice Example (Sum of 2D Matrix)

int mat[2][2], sum = 0; for(int i=0; i<2; i++){ for(int j=0; j<2; j++){ scanf("%d", &mat[i][j]); sum += mat[i][j]; } } printf("Sum = %d", sum);

✅ Task-5 (Required for PDF ✅)

Write a program to:

✔ Input size n
✔ Create array of n numbers
✔ Find smallest number in the array
✔ Print result

📌 Use for loop
📌 Use integer type

Example:

Input: 5 elements: 3 8 2 9 6 Output: Smallest = 2

➡ Send your code ✅


📝 Quick Quiz — Day-5

Reply like: 1A, 2C, 3B

1️⃣ In array, index starts from:
A) 0
B) 1
C) -1

2️⃣ 2D array is a collection of:
A) Strings
B) Characters
C) Arrays

3️⃣ Which statement is correct about arrays?
A) Store different data types
B) Continuous memory
C) Infinite size


✅ When you reply with:


✔ Task-5 code
✔ Quiz answers
➡ I will mark Day-5 Completed


Take your time — send Task-5 anytime ✅
Ready when you are! 😄


No comments

Thank You For Visit My Website.
I Will Contact As Soon As Possible.

Theme images by 5ugarless. Powered by Blogger.