Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

UPSC

Rating
-
Sold
-
Pages
18
Grade
A+
Uploaded on
29-04-2026
Written in
2025/2026

Basics of Programming Language

Institution
Course

Content preview

Unit 4
Array
4.2 One dimensional Array
4.3 Declaration of 1D
4.4 Initialization of 1D
4.5 2D arrays
4.6 initialization of 2D
4.7 Declaring and Initializing String Variable.
4.8. Reading string from terminal
4.9. writing string to screen
4.10 putting strings together
4.11 comparison of two strings
4.12 string handling functions.


4.1 Introduction
Array in C is one of the most used data structures in C programming. It is a
simple and fast way of storing multiple values under a single name.
What is Array in C?
An array in C is a fixed-size collection of similar data items stored in
contiguous memory locations. It can be used to store the collection of
primitive data types such as int, char, float, etc., and also derived and user-
defined data types such as pointers, structures, etc.

,Array Declaration

In C, we have to declare the array like any other variable before using it. We
can declare an array by specifying its name, the type of its elements, and the
size of its dimensions.

Syntax of Array Declaration

data_type array_name [size];
or
data_type array_name [size1] [size2]...[sizeN];
where N is the number of dimensions.




The C arrays are static in nature, i.e., they are allocated memory at the compile
time.
//simple array using static allocation
#include <stdio.h>

, int main()
{
int arr[5] = { 10, 20, 30, 40, 50 };
for (int i = 0; i < 5; i++)
{
printf("\n Numbers in Array=%d",arr[i]);
}
return 0;
}


//simple array using dynamic allocation
#include <stdio.h>
int main()
{
int a[5],i;
printf("Enter the numbers");
for ( i = 0; i < 5; i++)
{
scanf("%d",&a[i]);
}
for ( i = 0; i < 5; i++)
{
printf("\n %d",a[i]);
}
return 0;
}

Written for

Course

Document information

Uploaded on
April 29, 2026
Number of pages
18
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
malgesatish

Get to know the seller

Seller avatar
malgesatish KJEI
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 week
Number of followers
0
Documents
5
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions