aray notes revised
aray notes revised
Types of Array in C
There are two types of arrays based on the number of dimensions it has. They are as
follows:
2. Multidimensional Array in C
Multi-dimensional Arrays in C are those arrays that have more than one dimension.
Some of the popular multidimensional arrays are 2D arrays and 3D arrays. We can
declare arrays with more dimensions than 3d arrays but they are avoided as they get
very complex and occupy a large amount of space.
A. Two-Dimensional Array in C
A Two-Dimensional array or 2D array in C is an array that has exactly two
dimensions. They can be visualized in the form of rows and columns organized in a
two-dimensional plane.
Syntax of 2D Array in C
array_name[size1] [size2];
B. Three-Dimensional Array in C
Another popular form of a multi-dimensional array is Three Dimensional Array or 3D
Array. A 3D array has exactly three dimensions. It can be visualized as a
collection of 2D arrays stacked on top of each other to create the third dimension.
Syntax of 3D Array in C
array_name [size1] [size2] [size3];
Properties of Arrays in C
It is very important to understand the properties of the C array so that we can
avoid bugs while using it. The following are the main properties of an array in C:
1. Fixed Size
The array in C is a fixed-size collection of elements. The size of the array must
be known at the compile time and it cannot be changed once it is declared.
2. Homogeneous Collection
We can only store one type of element in an array. There is no restriction on the
number of elements but the type of all of these elements must be the same.
3. Indexing in Array
The array index always starts with 0 in C language. It means that the index of the
first element of the array will be 0 and the last element will be N – 1.
4. Dimensions of an Array
A dimension of an array is the number of indexes required to refer to an element in
the array. It is the number of directions in which you can grow the array size.
5. Contiguous Storage
All the elements in the array are stored continuously one after another in the
memory. It is one of the defining properties of the array in C which is also the
reason why random access is possible in the array.
6. Random Access
The array in C provides random access to its element i.e we can get to a random
element at any index of the array in constant time complexity just by using its
index number.
//ARRAY
//DECLATION-INITIALISATION-ACCESSING ELEMENTS IN AN ARRAY
C 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. When we declare an array in C, the compiler allocates the memory
block of the specified size to the array name.
int main()
{
return 0;
}
C Array Initialization
//#################################################### TRAVERSAL
######################################//
//#include<stdio.h>
//int main()
//{
//int i,a[10]={10,9,8,7,6,5,4,3,2,1};
//for(i=0;i<10;i++)
//printf("%d",a[i]);
//return 0;
//}
//
//return 0;
//}
//#include<stdio.h>
//int main()
//{
// int i,n,a[5],sum=0,mean=0;
//printf("enter no.of elements in an array ");
//scanf("%d",&n);
//for(i=0;i<5;i++)
//{
//printf("\n a[%d]=",i);
//scanf("%d",&a[i]);
//}
//for(i=0;i<5;i++)
//sum=sum+a[i];
//mean=sum/n;
//printf("sum of an array is %d",sum);
//#include<stdio.h>
//int main()
//{
// int n,i,a[50],pos=-1,small=111;
// printf("enter no. of elements in an array");
//scanf("%d",&n);
//for(i=0;i<n;i++)
//{
// printf("a[%d]=",i);
//scanf("%d",&a[i]);
//}
//for(i=0;i<n;i++)
//{
//if(a[i]<small)
// {
// small=a[i];
// pos=i;
//}
//}
// printf("\n smallest no. is :%d",small);
//printf("\n position of smallest no. is :%d",pos);
//return 0;
//}
//WAP TO INTERCHANGE THE LARGEST AND THE SMALLEST NUMBER IN AN ARRAY
//#include<stdio.h>
//int main()
// {
// int i,n,a[50],largest=-1,small=1111,small_pos=0,largest_pos=0,temp;
// printf("enter no. of elements in an array ");
// scanf("%d",&n);
// for(i=0;i<n;i++)
// {
// printf("a[%d]=",i);
// scanf("%d",&a[i]);
// }
// for(i=0;i<n;i++)
// {
// if(a[i]<small)
// {
// small=a[i];
// small_pos=i;
// }
// }
// for(i=0;i<n;i++)
// {
// if(a[i]>largest)
// {
// largest=a[i];
// largest_pos=i;
//}
// }
// printf("\n smallest no. is %d",small);
// printf("\n position of smallest no. is %d ",small_pos);
// printf("\n largest no. is %d",largest);
// printf("\n position of largest no. is %d ",largest_pos);
//
// temp=a[largest_pos];
// a[largest_pos]=a[small_pos];
// a[small_pos]=temp;
// printf("new array is ");
// for(i=0;i<n;i++)
// printf("\n a[%d]=%d",i,a[i]);
//return 0;
//}
//WAP TO READ MARKS OF 10 STUDENTS IN THE RANGE OF 0-100 .THEN MAKE 10 GROUPS 0-
10,10-20,....SO ON .
//COUNT NUMBER OF VALUES THAT FALLS IN EACH GROUP AND DISPLAY THE RESULT
//#include<stdio.h>
//int main()
//{
// int i,n,marks[100],group[10]={0},count=0;
// for(i=0;i<10;i++)
//{
//printf("marks[%d]= ",i);
//scanf("%d", &marks[i]);
//++group[(int)(marks[i])/10]; //GROUP() GROUPS THE ELEMENT OF CALLING
ARRAY ACCORDING TO THE STRING VALUES RETURNED BY A PROVIDED TESTING FUNCTION.....
//}
//printf("\n group \t\t frequency "); // "\t" USED FOR COUPLE OF SPACES IN
SAME LINE
//for(i=0;i<=10;i++)
//{
// printf(" \n %d \t\t %d,i,group[i]");
//}
// return 0;
//}
//############################################################# INSERTION
#################################################################################//
//for(i=0;i<n+1;i++)
// printf("%d",a[i]);
//return 0;
//}
//
###############################################################DELETION############
###############################################################################
//DELETE A NO. FROM A GIVEN LOCATION
//#include<stdio.h>
//int main()
//{
// int n,i,a[10],num,pos;
//printf("enter no. of elements in an array");
//scanf("%d",&n);
//for(i=0;i<n;i++)
//{
// printf("\n enter the values:");
//scanf("%d",&a[i]);
//}
// printf("\n enter the value to be deleted:");
//scanf("%d",&num);
//for(i=0;i<n+1;i++)
// printf("%d",a[i]);
//return 0;
//}
//
################################################MERGING############################
#######################################
//############################2D
ARRAYS#####################################################
//
###################################################################################
#######
//DECLARATION OF 2D ARRAY
//data_type_name[row size][column size];
//int marks[3][5];
//for(i=0;i<2;i++)
//{
// for(j=0;j<2;j++)
//{
// scanf("%d",&a[i][j]);
//}
//printf("\n the elements of the matrix are: \n");
//for(i=0;i<2;i++)
//{
// printf("\n");
//for(j=0;j<2;j++)
// printf("\t %d %d",i,j,a[i][j]);
//}
//}
//return 0;
//}
Advantages of Array in C
The following are the main advantages of an array:
Disadvantages of Array in C
-Allows a fixed number of elements to be entered which is decided at the time of
declaration. Unlike a linked list, an array in C is not dynamic.
-Insertion and deletion of elements can be costly since the elements are needed to
be rearranged after insertion and deletion.
//#######################################################################
//########################## STRINGS ####################################
char string_name[size];
C String Initialization
A string in C can be initialized in different ways. We will explain this with the
help of an example. Below are the examples to declare a string with the name str
and initialize it with “GeeksforGeeks”.
We can use the fgets() function to read a line of string and gets() to read
characters from the standard input (stdin) and store them as a C string until a
newline character or the End-of-file (EOF) is reached.
We can also scanset characters inside the scanf() function
1. Example of String Input using gets()
// C program to illustrate
// fgets()
#include <stdio.h>
#define MAX 50
int main()
{
char str[MAX];
return 0;
}
//INITIALISATION OF STRING
// char str[size];
//for example- In char str[100]....we can store a maximum of 99 usable characters
as last character is null character
//char str[10]="HELLO"
//OBSERVE HERE WE HAVE MENTIONED SIZE 10 SO COMPILER CREATES ARRAY OF SIZE
10 ...STORES STRING AND FINALLY TERMINATES STRING BY '/0'NULL CHARACTER
//char str2,str1[]="hi";
//str2=str1;
//In C programming, the %c and %s are format specifiers used to display the values
of variables in a formatted output.
//char ch = 'A';
//printf("The character is %c", ch);
//The %s format specifier, on the other hand, is used to print a string. It expects
an argument of type char*, which is a pointer to an array of characters (i.e., a
string).
// The printf function prints the characters in the string until it reaches a null
character '\0',
// which indicates the end of the string. For example, the following code will
print the string "hello" to the output screen:
//main problem with scanf() is that it terminates as soon as it find blank spaces
//for example if string contains "HELLO WORLD" it will only print "HELLO".
//return 0;
//}
//STRING OPERATIONS
//1-LENGTH:
//strlen(s1) returns length of string.
//int main()
//{
// int i;
//char str[50];
// printf("enter your string");
// gets(str);
// while(str[i]!='\0')
//{
// if(str[i]>='a' && str[i]<='z')
//{
// str[i]=str[i]-32;
// i++;
//}
// }
// puts(str);
//return 0;
//}
//int main()
//{
// int i;
//char str[50];
//printf("enter your string");
//gets(str);
//while(str[i]!='\0')
//{
// if(str[i]>='A' && str[i]<='Z')
// {
// str[i]=str[i]+32;
// i++;
//}
//}
//puts(str);
//return 0;
//}
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// char s1[1000],s2[1000];
// int i,j;
// for(i=0;s2[i]!='\0';i++)
//{
//s1[i+j]=s2[i];
//}
//s1[i+j]='\0';
//return 0;
//}
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// char s1[1000],s2[1000];
// int i,j;
// printf("Enter source string: ");
// gets(s1);
// printf("Enter destination string: ");
// gets(s2);
// while(s2[i]!='\0')
// i++;
// while(s1[i]!='\0')
//{
// s2[i]=s1[i];
// i++;
// j++;
//}
//s2[i]='\0';
//In order to compare two strings firstly we're required to check length of string
//#include<string.h>
//#include<stdio.h>
//int main()
//{
// char str1[10];
// char str2[10];
// int len1=0,len2=0,i;
// if(len1==len2)
// {
// if(str1[i]==str2[i])
// {
//}
//if(str1[i]!=str2[i])
// {
// }
// }
// if(len1!=len2)
// if(str1[i]!=str2[i])
// printf("strings are not equal");
//}
//strrev(s1): library function that reverses all the characters in the string
except null character.....it is defined in string.h
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// int i,len1;
// char str[100],temp;
// printf("enter string 1");
// gets(str);
// len1=strlen(str);
// while(i<len1)
// {
// temp=str[i];
// str[i]=str[len1-1];
// str[len1-1]=temp;
// i++;
// len1--;
//}
// printf("the reversed string is :");
// puts(str);
// return 0;
//}
//1-strcat: The strcat() function will append a copy of the source string to the
end of destination string. The strcat() function takes two arguments:
//1) dest (DESTINATION STRING)
//2) src (SOURCE STRING)
//It will append copy of the source string in the destination string. The
terminating character at the end of dest is replaced by the first character of
src .
//Return value: The strcat() function returns dest, the pointer to the destination
string.
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// char str1[100],str2[100];
// printf("enter string 1");
// gets(str1);
// printf("enter string 2");
// gets(str2);
// strcat(str1,str2);
// printf("modified string is:%s",str1);
//}
//2-strncat()function
//this function appends the strings pointed to by str2 to the end of the string 1
upto n charcters
//the terminating null charcter of string is overwritten
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// char str1[200];
// char str2[100];
// printf("enter string 1");
// gets(str1);
// printf("enter string 2");
// gets(str2);
// strncat(str1,str2,4);
// printf("modified string is :%s",str1);
//}
//3-strchr()function
//It returns pointer to first occourrence of character
//pointer indicates to position
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// char str[100];
// char ch='b';
// char *ptr;
// printf("enter string:");
// gets(str);
// printf (" Original string is: %s \n", str);
// ptr=strchr(str,'b');
// printf("\n the first occurrence of %c in string is :",ch,ptr,str);
//}
//#include<string.h>
//#include<stdio.h>
//int main()
//{
// int len1=0,len2=0;
// char str1[100],str2[100];
// printf("enter string 1 :");
// gets(str1);
// len1=strlen(str1);
// printf("enter string 2 :");
// gets(str2);
// len2=strlen(str2);
// if(strcmp(str1,str2)==0)
// printf("both the strings are equal");
// else
// printf("both the strings are unequal");
//}
//6-strncmp():this function compares at most the first n bytes of str1 and str2.
//the process stops comparing after null character is encountered.
//this function return zero if first n bytes of string are equal
//#include<string.h>
//#include<stdio.h>
//int main()
//{
// int len1=0,len2=0;
// char str1[100],str2[100];
// printf("enter string 1 :");
// gets(str1);
// len1=strlen(str1);
// printf("enter string 2 :");
// gets(str2);
// len2=strlen(str2);
// if(strncmp(str1,str2,2)==0)
// printf("both the strings are equal");
// else
// printf("both the strings are unequal");
//}
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// char str1[100];
// char str2[]="joshi";
// strcpy(str1,str2);
// puts(str1);
//}
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// char str1[100];
// printf("enter string 1");
// gets(str1);
// printf("length of string 1 is :%d",strlen(str1));
//}
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// char str1[]="happy bith day maa";
// char str2[]="maa";
// char *sub;
// sub=strstr(str1,str2);
// printf("the substring is :%s",sub);
//}
//C provides two functions strtok() and strtok_r() for splitting a string by some
delimiter. Splitting a string is a very common task.
// For example, we have a comma-separated list of items from a file and we want
individual items in an array.
//strtok() Method: Splits str[] according to given delimiters and returns the next
token.
//It needs to be called in a loop to get all tokens. It returns NULL when there are
no more tokens.
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// char str1[]="happy bith day maa";
// char delim[]=",";
// char *result;
// result=strtok(str1,delim);
// while(result!=NULL);
// {
// printf("%s",result);
// result=strtok(NULL,delim);
// }
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////
///////////////////////////////////////////////////
POINTERS////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
//Pointers - a variable that stores the memory address of another variable as its
value.
//In dynamic memory allocation you request the computer for memory. The compiler
goes and sees what memory it has available.
// Assuming it has enough to give us, the operating system will set aside the
amount of memory requested and give us that memory's address so that we can use it.
// How do we store an address ? In a pointer !! Allocation and de-allocation of
memory can be done easily using functions and thus pointers fit the case here.
//last but not the least ,the most powerful use of pointers is to dynamically
allocate memory for variables
//generally computer has three areas of memory each of which is used for specific
task
//3-GLOBAL MEMORY: the block of code that is in main() program is stored in global
memory.
// : the memory in global area is allocated randomly to store the
code of different functions in the program
// in such a way that one function is not
contiguous to other
//int a=5;
//int *ptr;
//ptr = &a;
//Here pointer ptr got address of variable a so, pointer ptr is now pointing to
variable a.
//Dereferencing of Pointer
//So far, the operator * (star) used in front of the name of the pointer variable
is known as pointer or dereferencing or indirection operator.
// After valid referencing of pointer variable, * pointer_variable gives the value
of the variable pointed by pointer variable and this is known as dereferencing of
pointer.
//For the sake of simplicity,
// *pointer_variable after referencing instructs compilers that go to the memory
address stored by pointer_variable and get value from that memory address.
//int a=5;
//int *ptr;
//ptr = &a;
//printf(“a = %d”, *ptr);
//SYNATX: data_type *ptr _name; (here data_type is the type of value that the
pointer will point to)
// (here * informs compiler that ptr is pointer
variable )
//eg:int*a;
// :float *b;
// :char *c;
//int x;
//int *ptr;
//ptr=&x;
//IN C ,pointers are not allowed to store memory address ,but they can store
address of variables of a given type
//therefore,
// int *ptr =1000;is absolutely illegal in c.
//#include<stdio.h>
//int main()
//{
// int a=9,b=5;
// int *pnum;
// pnum=&a;
// printf("\n a=%d",*pnum);
// pnum=&b;
// printf("\n b=%d",*pnum);
// return 0;
//}
//PROGRAMMING TIPS
//1-Its an an error to subtract two pointer variables
//2-A pointer variable can be assigned the address of another variable(same data
type)
//3-A pointer variable can be assigned the VALUE of another variable(same data
type)
//4-It can be initialized with NULL VALUE(/0) or ZERO VALUE
//5-WHEN USING POINTERS ,UNARY INCREMENT(++) AND DECREMENT (--)OPERATORS HAVE
GREATER PRECEDENCE THAN DEREFERENCE OPERATOR(*)
//6-AN integer value can be added or subtracted from a pointer variable
//7-A pointer variable can be compared with another pointer variable of same type
using relational operators
//8-A pointer variable can not be multiplied with constant
//9-A pointer variable can not be added to another pointer variable
//FOR EXAMPLE:
//#include<stdio.h>
//int main()
//{
// int n1=1,n2=2,sum=0,mul=0,div=0;
// int *ptr1,ptr2;
// ptr1=&n1;
// ptr2=&n2;
// sum=*ptr1 + 2;
// mul=*ptr1 * 2;
// div=*ptr1 / 2;
// printf("\n sum=%d",sum);
// printf("\n multiplication=%d",mul);
// printf("\n division =%d",div);
// return 0;
//}
//WAP TO ADD TWO FLOATING POINT NOS. USING POINTER .THE RESULT SHOULD CONTAIN ONLY
TWO DIGITS AFTER THE DECIMAL.
//#include<stdio.h>
//int main()
//{
// float num1,num2,sum;
// float *ptr1=&num1,*ptr2=&num2;
// sum=*ptr1 + num2;
// printf("\n sum of two nos. is %f + %f = %.2f",*ptr1,*ptr2,sum);
// return 0;
//}
//#include<stdio.h>
//int main()
//{
// char ch,*ptr=&ch;
// printf("enter a character :");
// scanf("%c",&ch);
// if(*ptr=='a'||*ptr=='e'||*ptr=='i'||*ptr=='o'||*ptr=='u' ||*ptr=='A'||
*ptr=='E'||*ptr=='I'||*ptr=='O'||*ptr=='U')
// printf("%c is vowel",*ptr);
// else
// printf("%c is not a vowel",*ptr);
// return 0;
//}
// }
// printf("total no. of uppercase characters are :%d",upper);
// printf("total no. of lowercase characters are :%d",lower);
// printf("total no. of entered characters are :%d",count);
//}
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////
////////////////////////////////////TYPES OF
POINTER///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////
//1-NULL POINTER:
// A null pointer has a reserved value that is called a null pointer
constant for indicating that the pointer does not point to any valid object or
function.
// You can use null pointers in the following cases: Initialize
pointers. Represent conditions such as the end of a list of unknown length.
//To declare a null pointer you must use predefined constant
NULL,which is defined in several standard header files <stdio.h>,<stdlib.h> and
<string.h>
//so now using these standarad header files we can write:
// int *ptr=NULL;
//2-GENERIC POINTER:
// A generic pointer is a pointer variable that has void as its data
type.
//the void or the generic pointer ,is a special type of pointer that
can be used to point to variables of any data type.
//SYNTAX:
// void *ptr;
//IN C , since you cannot have variable of type void ,the void pointer
will ,therefore not point to any data type thus,cannot be dereferenced.
//you need to typecast a void pointer(GENERIC POINTER) to another kind
of pointer before using it.
//generic pointers are often used when u want to point to data of
different types at different times .
//User-defined function
//You can also create functions as per your need. Such functions created by the
user are known as user-defined functions.
//int main()
//{
// ... .. ...
// ... .. ...
// functionName();
// ... .. ...
// ... .. ...
//}
//The execution of a C program begins from the main() function.
//void functionName()
//NOTE:
//1- while using pointers to pass argument to a function ,the calling
function must pass address of the variable as arguments and the called function
must dereference
//the arguments to use them in the
function body for processing.
//#include<stdio.h>
//int sum(int *a,int*b,int *t);
//int main()
//{
// int num1,num2,total;
// printf("enter no.1 :");
// scanf("%d",&num1);
// printf("enter no.2 :");
// scanf("%d",&num2);
// sum(&num1,&num2,&total);
// printf("total=%d",total);
// return 0;
//}
//int sum(int *a,int*b,int *t)
//{
// *t=*a + *b;
//}
//#include<stdio.h>
//int big(int *a,int *b,int *c,int*large);
//int main()
//{
// int num1,num2,num3,large=0;
// printf("enter a no.1 :");
// scanf("%d",&num1);
// printf("enter a no.2 :");
// scanf("%d",&num2);
// printf("enter a no.3 :");
// scanf("%d",&num3);
// big(&num1,&num2,&num3,&large);
// printf("large=%d",large);
// return 0;
//}
//int big(int *a,int *b,int *c,int*large)
//{
// if(*a>*b && *a>*c)
// *large=*a;
// if(*b>*a && *b>*c)
// *large=*b;
// if(*c>*a&& *c>*b)
// *large=*c;
//}
//example:
//int arr[]={1,2,3,4,5};
//array notation is a form of pointer notation .the name of array is the starting
address of the array in memory .
//it is also known as base address .in other words base address is the address of
first element in the array or the address of arr[0]
//for eg:
//int *ptr;
//ptr=&arr[0];
//#include<stdio.h>
//int main()
//{
// int arr[]={1,2,3,4,5};
// printf("\n Address of array = %p%p%p",&arr,&arr[0],&arr);//In C we have seen
different format specifiers. Here we will see another format specifier called %p.
// This
is used to print the pointer type data.
//}
//IF THE POINTER VARIABLE ptr HOLDS THE ADDRESS OF THE FIRST ELEMENT IN THE
ARRAY ,THEN THE ADDRESS OF SUCCESSIVE ELEMENTS CAN BE CALCULATED BY WRITING ptr++
//#include<stdio.h>
//int main()
//{
// int arr[]={1,2,3,4,5};
// int *ptr=&arr[0];
// ptr++;
// printf("\n the value of the second element of the array is %d",*ptr);
//}
//NOTE:
//if x is an integer variable ,then x++,adds 1 to the value of x.
//but ptr is a pointer variable ,
//so when we write ptr+i,then adding i
gives a pointer that points i elements further along an array than the original
pointer.
//LOOK AT THE CODE AND TRY TO UNDERSTAND THE RESULT:
//#include<stdio.h>
//int main()
//{
// int arr[]={1,2,3,4,5};
// int *ptr,i;
// ptr=&arr[2];
// *ptr=-1;
// *(ptr+1)=0;
// *(ptr-1)=1;
// printf("\n Array is :");
// for(i=0;i<5;i++)
// printf("%d",*(arr+i));
//}
//#include<stdio.h>
//main()
//{
//int a[5]={5,4,6,8,9};
//int *p=&a[0];
//int i;
//for(i=0;i<5;i++)
//printf("%d ",*(p+i));
//}
//In C,strings are treated as array of characters that are terminated with a binary
zero character (written as '\0')
//consider one example here:
//char str[10];
//str[0]='H';
//str[1]='i';
//str[2]='i';
//str[3]='\0';
//C LANGUAGE PROVIDES TWO ALTERNATIVE WAYS OF DECLARING AND INITIALISING STRING:
//WAP TO READ AND PRINT A TEXT .ALSO COUNT THE NUMBER OF CHARCTERS ,WORDS ,AND
LINES IN THE TEXT.
//#include<stdio.h>
//int main()
//{
// char str[100],*ptr=&str;
// int ccount=0,lcount=0,wcount=0;
// printf("enter a string :");
// gets(str);
// ptr=str;
// while(*ptr!='\0')
// {
// if(*ptr=='\n')
// lcount++;
//
// else if(*ptr=' ')
// wcount++;
//
// else (*ptr!=' ' && '\n');
// ccount++;
// }
// printf("the string is %s");
// gets(str);
// printf("no. of lines :%d",lcount);
// printf("no. of words :%d",wcount);
// printf("no. of characters :%d",ccount);
// return 0;
//}
//WAP TO READ A TEXT ,DELETE ALL THE SEMI COLANS IT HAS,AND FINALLY REPLACE ALL
'.' WITH A ','
//#include<stdio.h>
//int main()
//{
// char string[100],*ptr=&string;
// printf("enter a string");
// gets(string);
// string=string.replace(";","");
// gets(string);
//}
//in c language you are allowed to use pointers that point to pointers .the
pointers in turn ,point to data (or to other pointer )
//to declare pointer to pointers ,just add an (*)asterisk for each level of
reference .
//#include<stdio.h>
//int main()
//{
// int x=40,*px,**ppx;
// px=&x;
// ppx=&px;
// printf("%d",**ppx);
//}