- An array must be declared with type of variable or data type
- An array contains same type of data
e.g. – int a [10] - The name of array cannot be same as that of any other variable within the function.
- The size of array is specified using sub-script notation (index)
- THE sub-script indicates that how many elements are to be allocated to an array.
- A sub-script used to declare an array is called dimension
DECLARE ARRAYS
ARRAYS
Arrays are widely used data type in ‘C’ language. It is a collection of elements of similar data type. These similar elements could be of all integers, all floats or all characters. An array of character is called as string whereas and array of integer or float is simply called as an array. So array may be defined as a group of elements that share a common name and that are defined by position or index. The elements of an arrays are store in sequential order in memory.
WAP to input your name and display it
#include
void main ( )
{
char nm [15];
clrscr ( );
printf (“enter your name”);
gets (nm);
printf (“name is %s”,name);
getch ( );
}
STRING
String are the combination of number of characters these are used to store any word in any variable of constant. A string is an array of character. It is internally represented in system by using ASCII value. Every single character can have its own ASCII value in the system. A character string is stored in one array of character type.
e.g. “Ram” contains ASCII value per location, when we are using strings and then these strings are always terminated by character ‘\0’. We use conversion specifier %s to set any string we can have any string as follows:-
char nm [25]
When we store any value in nm variable then it can hold only 24 character because at the end of the string one character is consumed automatically by ‘\0’.
1. strlen - string length
2. strcpy - string copy
3. strcmp - string compare
4. strups - string upper
5. strlwr - string lower
6. strcat - string concatenate
7. strstr - string string
BROWSE C PROGRAMS WITH OUTPUT
- %AGE OF TOTAL MARKS
- ADD TWO VARIABLES
- AREA OF CIRCLE
- BIGGER & EQUAL
- BIGGER NUMBER 1
- BIGGER NUMBER 2
- CALCULATE TOTAL MARKS
- CELCIUS TO FAHRENHEIT
- POWER OF VARIABLE
- PRINT MESSAGE
- SQUARE ROOT
- SUM,SUB,PRODUCT,DIVISION
- TOTAL BILL/ DISCOUNT A
- TOTAL SALARY
- VALUE OF DATA TYPE
- Z >>>> Click here to browse all C Programs <<<<<<< <<<< Z
