Posts

Showing posts from September, 2020

C - 2D Array

Image
 Two dimensional arrays : Two dimensional array is known as matrix. The array declaration in both the array i.e.in single dimensional array single subscript is used and in two dimensional array two subscripts are is used.  Its syntax is  Data-type array name[row][column];  Or we can say 2-d array is a collection of 1-D array placed one below the other. Total no. of elements in 2-D array is calculated as row*column  Example:-   int a[2][3];   Total no of elements=row*column is 2*3 =6  It means the matrix consist of 2 rows and 3 columns  For example:-   20        2        7    8         3       15  Positions of 2-D array elements in an array are as below  00       01       02  10       11       12  Accessing 2-d array /processing 2-d...

C - Array

 Array Array is the collection of similar data types or collection of similar entity stored in contiguous memory location. Array of character is a string. Each data item of an array is called an element. And each element is unique and located in separated memory location. Each of elements of an array share a variable but each element having different index no. known as subscript.  An array can be a single dimensional or multi-dimensional and number of subscripts determines its dimension. And number of subscript is always starts with zero. One dimensional array is known as vector and two dimensional arrays are known as matrix.  ADVANTAGES: array variable can store more than one value at a time where other variable can store one value at a time.  Example:   int arr[100]; int mark[100]; DECLARATION OF AN ARRAY :   Its syntax is :   Data type array name [size];   int arr[100];   int mark[100];  int a[5]={10,20,30,10...

C - break and continue

 Break and Continue: Break Vs Continue break continue A  break  can appear in both  switch  and loop ( for ,  while ,  do ) statements. A  continue  can appear only in loop ( for ,  while ,  do ) statements. A  break  causes the  switch  or loop statements to terminate the moment it is executed. Loop or  switch  ends abruptly when break is encountered. A  continue  doesn't terminate the loop, it causes the loop to go to the next iteration. All iterations of the loop are executed even if  continue  is encountered. The  continue  statement is used to skip statements in the loop that appear after the  continue . The  break  statement can be used in both  switch  and loop statements. The  continue  statement can appear only in loops. You will get an error if this appears in switch statement. When a  break  statement is encountered, i...

C - Loops

 Loops in C: Loop:-it is a block of statement that performs set of instructions. In loops Repeating particular portion of the program either a specified number of time or until a particular no of condition is being satisfied.  There are three types of loops in c  1.While loop  2.do while loop  3.for loop   While loop: Syntax:-  while(condition)  {  Statement 1;  Statement 2;  }  Or  while(test condition)  Statement;  The test condition may be any expression .when we want to do something a fixed no of times but not known about the number of iteration, in a program then while loop is used.  Here first condition is checked if, it is true body of the loop is executed else, If condition is false control will be come out of loop.  Example:-  /* wap to print 5 times welcome to C” */   #include  <stdio.h> void main()  {  int p=1;  While(p<=5)  {  printf(“Welcome ...