Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

Computer system

Beoordeling
-
Verkocht
-
Pagina's
20
Geüpload op
24-07-2023
Geschreven in
2017/2018

Computer system, computer science, computer skills, computer language,

Instelling
Vak

Voorbeeld van de inhoud

Enter 12 values:

123456789101112

Displaying Values:

test[0][0][0] = 1

test[0][0][1] = 2

test[0][1][0] = 3

test[0][1][1] = 4

test[0][2][0] = 5

test[0][2][1] = 6

test[1][0][0] = 7

test[1][0][1] = 8

test[1][1][0] = 9

test[1][1][1] = 10

test[1][2][0] = 11

test[1][2][1] = 12




STRINGS:
String Concepts

String is an array of characters that is terminated by \0 (null character). This null
character indicates the end of the string. Strings are always enclosed by double quotes ( "
" ). Whereas, character is enclosed by single quotes.

Or



C PROGRAMMING Page 111

, In „C‟ language the group of characters, digits, and symbols enclosed within double
quotation ( " " ) marks are called as string otherwise a string is an array of characters and
terminated by NULL character which is denoted by the escape sequence „\0‟.

C Strings

Declaration of String: C does not support string as a data type. However, it allows us to
represent strings as character arrays. In C, a string variable is any valid C variable name and it is
always declared as an array of characters.

The general form of declaration of a string variable is :

Syntax: char string_name[size];

The size determines the number of characters in the string name.

Note: In declaration of string size must be required to mention otherwise it gives an error.

Ex: char str[]; // Invalid

char str[0]; // Invalid

char str[-1]; // Invalid

char str[10]; // Valid

char a[9]; //Valid

Using this declaration the compiler allocates 9 memory locations for the variable a
ranging from 0 to 8.



0 1 2 3 4 5 6 7 8




Here, the string variable a can hold maximum of 9 characters including NULL(\0)
character.

Initializing Array string

Syntax : char string_name[size]={“string” };

Note: In Initialization of the string if the specific number of character is not initialized it then
rest of all character will be initialized with NULL.

C PROGRAMMING Page 112

, char str[5]={'5','+','A'};

str[0]; ---> 5

str[1]; ---> +

str[2]; ---> A

str[3]; ---> NULL

str[4]; ---> NULL

Note: In initialization of the string we can not initialized more than size of string elements.

Ex:

char str[2]={'5','+','A','B'}; // Invalid

Different ways of initialization can be done in various ways :

1 : Initilizing locations character by character.

2 : Partial array initialization.

3 : Intilization without size.

4 : Array initialization with a string .

1 : Initilizing locations character by character

Consider the following declaration with initialization,

Char b[9]={„C‟,‟O‟,‟M‟,‟P‟,‟U‟,‟T‟,‟E‟,‟R‟};

The compiler allocates 9 memory locations ranging from 0 to 8 and these locations are
initialized with the characters in the order specified. The remaining locations are automatically
initialized to null characters.



C O M P U T E R \0

0 1 2 3 4 5 6 7 8



2 : Partial Array Initilization : If the characters to be initialized is less than the size of the
array, then the characters are stored sequentially from left to right.The remaining locations will
be initialized to NULL characters automatically.
C PROGRAMMING Page 113

Geschreven voor

Study Level
Publisher
Subject
Course

Documentinformatie

Geüpload op
24 juli 2023
Aantal pagina's
20
Geschreven in
2017/2018
Type
College aantekeningen
Docent(en)
Prof
Bevat
Alle colleges

Onderwerpen

€19,36
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kan je een ander document kiezen. Je kan het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
akhilagouri

Maak kennis met de verkoper

Seller avatar
akhilagouri A Level Notes
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
2 jaar
Aantal volgers
0
Documenten
107
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Populaire documenten

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via Bancontact, iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo eenvoudig kan het zijn.”

Alisha Student

Veelgestelde vragen