The document discusses various aspects of arrays in C programming, including:
- Declaring and initializing one-dimensional arrays
- Accessing array elements using pointers and indexes
- Declaring and initializing two-dimensional arrays
- Passing arrays to functions by passing the base address
- Declaring arrays of pointers where each element is a pointer variable
Gentle Introduction to Functional ProgrammingSaurabh Singh
This slide is basically aimed at professionals and students to introduce them with functional programming.
I haven't used much functional programming terminologies because I personally feel they could be overwhelming to people getting introduced to FP for the first time. For similar reasons I have deliberately avoided using any functional programming language and kept the discussions programming language agnostic as far as possible.
Gentle Introduction to Functional ProgrammingSaurabh Singh
This slide is basically aimed at professionals and students to introduce them with functional programming.
I haven't used much functional programming terminologies because I personally feel they could be overwhelming to people getting introduced to FP for the first time. For similar reasons I have deliberately avoided using any functional programming language and kept the discussions programming language agnostic as far as possible.
N-Queens Combinatorial Problem - Polyglot FP for fun and profit - Haskell and...Philip Schwarz
Learn how to write FP code that displays a graphical representation of all the numerous N-Queens solutions for N=4,5,6,7,8 .
See how to neatly solve the problem by exploiting its self-similarity and using a divide and conquer approach.
Make light work of assembling multiple images into a whole, by exploiting Doodle’s facilities for combining images using a relative layout.
See relevant FP functions, like Foldable’s intercalate and intersperse, in action.
Code for part 3: https://github.com/philipschwarz/n-queens-combinatorial-problem-scala-part-3
In detail and In very simple method That can any one understand.
If you read this all you doubts about function will be clear.
because i have used very simple example and simple English words that you can pick quickly concept about functions.
#inshallah.
Modes of Operation and its applications
Multiple Encryption and Meet-in-the Middle Attack
SHA-1 and SHA-3
HMAC and CBC-MAC and its Security
CBC-MAC implementation
Thesen: Was macht ein Video zum Web-Video?
Diskussionsmaterial (Version für 2015).
Ein kleines Kompendium zur Entwicklung, Planung, Produktion und Vertrieb optimaler Web-Videos.
Die folgenden Thesen und Fakten liefern die elementaren Fragen für die Diskussion.
Sie liefern selten Rezepte, sondern das Material, um eigene passende Rezepte zu finden.
N-Queens Combinatorial Problem - Polyglot FP for fun and profit - Haskell and...Philip Schwarz
Learn how to write FP code that displays a graphical representation of all the numerous N-Queens solutions for N=4,5,6,7,8 .
See how to neatly solve the problem by exploiting its self-similarity and using a divide and conquer approach.
Make light work of assembling multiple images into a whole, by exploiting Doodle’s facilities for combining images using a relative layout.
See relevant FP functions, like Foldable’s intercalate and intersperse, in action.
Code for part 3: https://github.com/philipschwarz/n-queens-combinatorial-problem-scala-part-3
In detail and In very simple method That can any one understand.
If you read this all you doubts about function will be clear.
because i have used very simple example and simple English words that you can pick quickly concept about functions.
#inshallah.
Modes of Operation and its applications
Multiple Encryption and Meet-in-the Middle Attack
SHA-1 and SHA-3
HMAC and CBC-MAC and its Security
CBC-MAC implementation
Thesen: Was macht ein Video zum Web-Video?
Diskussionsmaterial (Version für 2015).
Ein kleines Kompendium zur Entwicklung, Planung, Produktion und Vertrieb optimaler Web-Videos.
Die folgenden Thesen und Fakten liefern die elementaren Fragen für die Diskussion.
Sie liefern selten Rezepte, sondern das Material, um eigene passende Rezepte zu finden.
... NEW Version Oct 2015 ...
Please download this document for better reading. It's a small brochure, not a presentation.
Find this guide as eBOOK at https://leanpub.com/one-page-storytelling
- - - - - - - - - - - - - - - -
immersive storytelling:
how to build the most stunning multi-media story:
a small and concise guide to ONE-PAGE-STORYTELLING.
types – storyline – storyboard – examples.
For use with Shorthand.com and other tools or platforms.
A small guide to plan and produce one-page aka parallax storytelling: with links to examples and resources, copy template for storyline and step-by-step instructions.
- - - - - - - - - - - - - -
Thanks for great discussions, feedback and additions:
Jeremy Caplan,
Director of Education, Tow-Knight Center Entrepreneurial Journalism, CUNY Graduate School of Journalism (http://www.jeremycaplan.com),
Rachel Bartlett,
Editorial planning and training manager for @Shorthand_, former editor of http://Journalism.co.uk (https://twitter.com/rachelabartlett)
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
1sequences and sampling. Suppose we went to sample the x-axis from Xmin to Xmax using a
step size of step
A)Draw a picture of what is going on.
B) Write a expression for n the total number of samples involved (in terms of Xmin, Xmax and
step)
C) Write out the sequence of x-samples
D) Write a direct and general expression for xi that captures the sequence
E) Write a recursive expression for the sequence
F) Write a program to compute and store the x-samples over the range -5x5 using a step size of
0.1 do everything in main ()
2 . We talked about the following string functions that are available in C (as long as you include
string.h):
int strlen(char str[])
void strcpy(char str1[], char str2[])
void strcat(char str1[], str2[])
Write your own versions of these functions; for example: int paul_strlen(int char str[]). Hint: for
your version of the strlen function, start at the first character in the array and keep counting until
you find the ‘\\0’ character (use a while loop for this). Note: Use your version of the strlen
function in the strcpy and strcat functions.
9. We want to insert a number into an array.
(a) Formulate the problem mathematically with two sequences: x and y. (b) Write a function of
the form:
insertNumIntoArray(int n, int array[], int num, int index)
The function inserts num into the array at the specified index. The rest of the array then follows.
For example, if num = 9 and index = 3 and array = [7 2 8 8 3 1 2] then the function will produce:
array = [7 2 8 9 8 3 1 2]
Note: assume that array is properly dimensioned to have at least 1 extra space for storage.
10. Repeat #2 by for the delete operation; that is, we want to delete a single element (at a
specified index) from an array; for example, suppose index = 3 and array = [50 70 10 90 60 20],
then the result will be
array: [50 70 10 60 20]
11. Repeat #2 by for an insert operation where we are inserting several values into the array. The
function should be of the form:
int insertArrayIntoArray(int n, int inArray[],
int nInsert, int insertArray[], int outArray[], int index)
The dimension of outArray is returned (explicitly). For example:
inArrayarray: [7 2 8 6 3 9]
insertArray: [50 60 70]
index: 2
outArray: [7 2 50 60 70 8 6 3 9]
Assume that outArray is large enough to hold all n + nInsert values.
Solution
#include
//Simulates strlen() library function
int paul_strlen(char str[])
{
int l;
for(l = 0; str[l] != \'\\0\'; l++) ;
return l;
}
//Simulates strcpy() library function
void paul_strcpy(char str1[], char str2[])
{
int c;
for(c = 0; str1[c] != \'\\0\'; c++)
str2[c] = str1[c];
str2[c] = \'\\0\';
printf(\"\ Original String: %s\", str1);
printf(\"\ Copied String: %s\", str2);
}
//Simulates strcat() library function
void paul_strcat(char str1[], char str2[])
{
int i, j;
for(i = 0; str1[i] != \'\\0\'; i++) ;
for (j = 0; str2[j] != \'\\0\'; i++, j++)
{
str1[i] = str2[j];
}
str1[i] = \'\\0\';
printf(\"\ Concatenated String: %s\", str1);
}
int main()
{
char data1[20], data2[20];
pri.
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
ARRAYS
TYPES OF ARRAYS
MULTIDIMENSIONAL ARRAYS
CHARACTER HANDLING IN C
STRING HANDLING IN C
QUIZ SET 2
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...ssuserd6b1fd
C programming language notes for beginners and Collage students. Written for beginners. Colored graphics. Function by Function explanation with complete examples. Well commented examples. Illustrations are made available for data dealing at memory level.
03 of 03 parts
Get Part 1 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-1
Get Part 2 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-2
C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, while a static type system prevents unintended operations. C provides constructs that map efficiently to typical machine instructions and has found lasting use in applications previously coded in assembly language. Such applications include operating systems and various application software for computers, from supercomputers to PLCs and embedded system.
1. Array
array is a collection of similar elements.
program to find average marks obtained by a class of 30 students in a test.
main( )
{
int i, avg, sum = 0 ;
int marks[30] ; /* array declaration */
for ( i = 0 ; i <= 29 ; i++ )
{
printf ( "nEnter marks " ) ;
scanf ( "%d", &marks[i] ) ; /* store data in array */
}
for ( i = 0 ; i <= 29 ; i++ )
sum = sum + marks[i] ; /* read data from an array*/
avg = sum / 30 ;
printf ( "nAverage marks = %d", avg ) ;
}
Array Initialisation
int num[6] = { 2, 4, 12, 5, 45, 5 } ;
int n[ ] = { 2, 4, 12, 5, 45, 5 } ;
float press[ ] = { 12.3, 34.2 -23.4, -11.3 } ;
Pointers and Arrays
main( )
{
int i = 3, *x ;
float j = 1.5, *y ;
char k = 'c', *z ;
printf ( "nValue of i = %d", i ) ;
printf ( "nValue of j = %f", j ) ;
printf ( "nValue of k = %c", k ) ;
x = &i ;
y = &j ;
z = &k ;
printf ( "nOriginal address in x = %u", x ) ;
2. printf ( "nOriginal address in y = %u", y ) ;
printf ( "nOriginal address in z = %u", z ) ;
x++ ;
y++ ;
z++ ;
printf ( "nNew address in x = %u", x ) ;
printf ( "nNew address in y = %u", y ) ;
printf ( "nNew address in z = %u", z ) ;
}
output of the program
Value of i = 3
Value of j = 1.500000
Value of k = c
Original address in x = 65524
Original address in y = 65520
Original address in z = 65519
New address in x = 65526
New address in y = 65524
New address in z = 65520
Example:
main( )
{
int num[ ] = { 24, 34, 12, 44, 56, 17 } ;
int i, *j ;
j = &num[0] ; /* assign address(suppose 65512) of zeroth element */
for ( i = 0 ; i <= 5 ; i++ )
{
printf ( "naddress = %u ", j ) ;
printf ( "element = %d", *j ) ;
j++ ; /* increment pointer to point to next location */
}
3. }
The output of this program would be:
address = 65512 element = 24
address = 65514 element = 34
address = 65516 element = 12
address = 65518 element = 44
address = 65520 element = 56
address = 65522 element = 17
All the statements are same as
num[i]
*( num + i )
*( i + num )
i[num]
Example:
/* Accessing array elements in different ways */
main( )
{
int num[ ] = { 24, 34, 12, 44, 56, 17 } ;
int i ;
for ( i = 0 ; i <= 5 ; i++ )
{
printf ( "naddress = %u ", &num[i] ) ;
printf ( "element = %d %d ", num[i], *( num + i ) ) ;
printf ( "%d %d", *( i + num ), i[num] ) ; }
}
The output of this program would be:
address = 65512 element = 24 24 24 24
address = 65514 element = 34 34 34 34
address = 65516 element = 12 12 12 12
address = 65518 element = 44 44 44 44
address = 65520 element = 56 56 56 56
4. address = 65522 element = 17 17 17 17
Two Dimensional Arrays
While initializing a 2-D array it is necessary to mention the second (column) dimension, whereas the
first dimension (row) is optional.e.g.
int stud[4][2] = { { 1234, 56 }, { 1212, 33 }, { 1434, 80 }, { 1312, 78 } } ;
same as
int stud[4][2] = { 1234, 56, 1212, 33, 1434, 80, 1312, 78 } ;
same as
int stud[][2] = { 1234, 56, 1212, 33, 1434, 80, 1312, 78 } ;
Also,
s[2][1]
is same as
* ( s[2] + 1 )
same as
*(*(s+2)+1)
Example:
/* Pointer notation to access 2-D array elements */
main( )
{
int s[4][2] = { { 1234, 56 }, { 1212, 33 }, { 1434, 80 }, { 1312, 78 } } ;
int i, j ;
for ( i = 0 ; i <= 3 ; i++ )
{
printf ( "n" ) ;
for ( j = 0 ; j <= 1 ; j++ )
printf ( "%d ", *( *( s + i ) + j ) ) ;
}
}
And here is the output...
1234 56
1212 33
1434 80
1312 78
5. Pointer to an Array
/* Usage of pointer to an array */
main( )
{
int s[5][2] = { { 1234, 56 }, { 1212, 33 }, { 1434, 80 }, { 1312, 78 }} ;
int ( *p )[2] ;
int i, j, *pint ;
for ( i = 0 ; i <= 3 ; i++ )
{
p = &s[i] ;
pint = p ;
printf ( "n" ) ;
for ( j = 0 ; j <= 1 ; j++ )
printf ( "%d ", *( pint + j ) ) ;
}
}
And here is the output...
1234 56
1212 33
1434 80
1312 78
Here p is a pointer to an array of two integers. Note that the parentheses in the declaration of p are
necessary. Absence of them would make p an array of 2 integer pointers. In the outer for loop each
time we store the address of a new one-dimensional array. Thus first time through this loop p
would contain the address of the zeroth 1-D array. This address is then assigned to an integer
pointer pint. Lastly, in the inner for loop using the pointer pint we have printed the individual
elements of the 1-D array to which p is pointing.
Passing 2-D Array to a Function
/* Three ways of accessing a 2-D array */
main( )
{
int a[3][4] = {
1, 2, 3, 4,
5, 6, 7, 8,
9, 0, 1, 6
};
clrscr( ) ;
display ( a, 3, 4 ) ;
show ( a, 3, 4 ) ;
print ( a, 3, 4 ) ;
}
display ( int *q, int row, int col )
{
6. int i, j ;
for ( i = 0 ; i < row ; i++ )
{
for ( j = 0 ; j < col ; j++ )
printf ( "%d ", * ( q + i * col + j ) ) ;
printf ( "n" ) ;
}
printf ("n" ) ;
}
show ( int ( *q )[4], int row, int col )
{
int i, j ;
int *p ;
for ( i = 0 ; i < row ; i++ )
{
p=q+i;
for ( j = 0 ; j < col ; j++ )
printf ( "%d ", * ( p + j ) ) ;
printf ( "n" ) ;
}
printf ( "n" ) ;
}
print ( int q[ ][4], int row, int col )
{
int i, j ;
for ( i = 0 ; i < row ; i++ )
{
for ( j = 0 ; j < col ; j++ )
printf ( "%d ", q[i][j] ) ;
printf ( "n" ) ;
}
printf ( "n" ) ;
}
And here is the output…
1234
5678
9016
1234
5678
9016
1234
5678
9016
In the display( ) function we have collected the base address of the 2-D array being passed to it in
an ordinary int pointer. Then through the two for loops using the expression * ( q + i * col + j ) we
have reached the appropriate element in the array. Suppose i is equal to 2 and j is equal to 3, then
we wish to reach the element a[2][3].
7. The expression * ( q + i * col + j ) becomes * ( 65502 + 2 * 4 + 3). This turns out to be * (65502 +
11 ). Since 65502 is address of an integer, * ( 65502 + 11 ) turns out to be * (65524). Value at this
address is 6. A more general formula for accessing each array element would be:
* ( base address + row no. * no. of columns + column no.)
In the expression, int ( *q )[4] , q holds the base address of the zeroth 1-D array, i.e. 4001. This address is
then assigned to p, an int pointer, and then using this pointer all elements of the zeroth 1-D array are
accessed. Next time through the loop when i takes a value 1, the expression q + i fetches the address
of the first 1-D array. This is because, q is a pointer to zeroth 1-D array and adding 1 to it would give
us the address of the next 1-D array. This address is once again assigned to p, and using it all
elements of the next 1-D array are accessed.
In the print( ), int q[ ][4] ; is same as int ( *q )[4], where q is pointer to an array of 4 integers. The only
advantage is that we can now use the more familiar expression q[i][j] to access array elements.
Array of Pointers
The addresses present in the array of pointers can be addresses of isolated variables or addresses of
array elements or any other addresses.
main( )
{
int *arr[4] ; /* array of integer pointers */
int i = 31, j = 5, k = 19, l = 71, m ;
arr[0] = &i ;
arr[1] = &j ;
arr[2] = &k ;
arr[3] = &l ;
for ( m = 0 ; m <= 3 ; m++ )
printf ( "%d ", * ( arr[m] ) ) ;
}