Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Title: main c language function
Description: required c language function,loop,statement and pointer
Description: required c language function,loop,statement and pointer
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
Ke ywords:
D a ta type:
1
...
Sign qualifiers- signed and unsigned (These qualifiers can be applied to the data types int and char o nly)
C o nstant:
The term constant means that it does not change during the execution of program
...
Integer constants –const int
2
...
Character constants –const char (e
...
, ‘A’ ‘B’ ‘1’)
4
...
#define PI 3
...
Operators:
Ari thmetic operators:
Op e rator
Me aning
+
Addition or Unary plus
-
Subtraction or Unary minus
*
Multiplication
/
Division
%
modulo Division
R e lational operators:
Op e rator
Me aning
<
Less than
>
Greater than
<=
Less than or equal to
>=
Greater than or equal to
==
Equal to
!=
Not equal to
L o gical operators:
Op e rator
Me aning
&&
Logical AND
||
Logical OR
!
Logical NOT
Assignment operator:
Operator
Equation
Ou tput
+=
i =i +1
i +=1
-=
i =i -10
i -=10
*=
i =i*11
i * =11
/=
i =i /12
i /=12
%=
i =i%5
i % =5
C o nditional operator:
The conditional expression can be used as shorthand for some if-else statements
...
This
operator consist of two symbols: the question mark (?) and the colon (:)
...
If it is true (non-zero), it evaluates and returns expression1
...
if (x < y)
{
min = x;
}
else
{
min = y;
}
You just say
...
U n ary minus
2
...
Si zeof operator
4
...
%i
Data item is displayed as a single decimal integer
...
%c
Data item is displayed as a single character
...
%g
Data item is displayed as a floating-point value using either e-type or f-type
conversion depending on value
...
%s
Data item is displayed as string
...
%x
Data item is displayed as a hexadecimal integer, without a leading 0x
...
g e tch:
g e ts: char *gets(char *s);
It is used to scan a line of text from a standard input device
...
p u ts: p u ts();
It i s used to display a string on a standard output device
Arrays:
i n t numbers [5];
n u mbers [0] = 1;
// set first element
n u mbers [4] = 5;
// set last element
D a ta_type
Array_name [row size][column size];
i n t matrix [3][3];
m a trix[0][0] = 10
m a trix[2][2] = 10;
D a ta_type
Array_name [size1][size2][size3];
Fu n ction:
Fu n ction declaration: Void ariaofsquare(int);
Fu n ction calling: ariaofsquare(5);
Fu n ction definition:
Void ariaofsquare(intS)
{
}
R e curasion:
#include
type element n;
};
We can declare structure variables as follows
struct structure_name var1,var2,…
...
struct structure_name
{
type element 1;
type element 2;
……………
...
name
similarly, stud1’s rollno and stud1’s totalmark can be accessed by writing
stud1
...
totalmark
In i tializing Structure Members
The general form is
struct stucture_name var={val1,val2,val3…
...
h>
#include
2f\n",stud1
...
name,stud1
...
2f\n",stud2
...
name,stud2
...
2f\n",stud3
...
name,stud3
...
struct struct_name
{
type element 1;
type element 2;
……………
...
h>
#include
name);
printf("Roll number:\n");
scanf("%d",&stud[i]
...
totalmark);
}
printf("STUDENTS DETAILS:\n");
for(i=0;i
printf("\nRoll number:%d\n",stud[i]
...
name);
printf("Totel mark:%d\n",stud[i]
...
In such situation, the declaration of the embedded
structure must appear before the declaration of the outer structure
...
h>
#include
name);
p rintf("\nRoll number:\n");
scanf("%d",&stud[i]
...
totalmark);
p rintf("\nDate of birth (Format:01 06 2010):\n");
scanf("%d%d%d",&stud[i]
...
day,&stud[i]
...
month,&stud[i]
...
year);
}
printf("STUDENTS DETAILS:\n");
for(i=0;i
printf("\n\nRoll number:%d\n\n",stud[i]
...
name);
printf("Totel mark:%d\n\n",stud[i]
...
d
...
d
...
d
...
The size of
pointer variable depends on the data type of the variable pointed to by the pointer
Op e ration possible with pointers:
The arithmetic operations available for use with pointer can be classified as
U n ary operator: ++ (increment) and --
Bi nary operator; +(addition) and –(subtraction)
If the pointer to an integer is incremented using the ++ operator, then the address contained in the pointer is
incremented by two and not one, assuming that an integer occupies two bytes in memory
...
Sto rage Classes:
Sta tic storage:
re gister storage:
Au tomatic storage class:
External Storage class:
D ynamic memory allocation:
DMA
malloc
calloc
realloc
free
Fi le:
fopen
fclose
fputc
fgetc
fputs
fgets
fscanf
fprintf
fseek
putc
getc
putw
getw
append
C Preprocessor:
Preprocessor statements begin with a #symbol, and are NOT terminated by a semicolon
...
In clude directive:
They include directive is used to include files like as we include header files in the beginning of the
program using #include directive like
#include
h>
2
...
These defined values or statement can be used by main or in the user defined functions as well
...
defining a constant
B
...
defining a mathematical expression
For example
#define PI 3
...
char str1[]=”I Like”;
char *str2=”C Programming”;
strlen() : size_t strlen( char *str );
strlen(char *str) returns the length of the null terminated string pointed to by str
...
strlwr(): char * strlwr(char *str)
strlwr(str) coverts str to all lowercase
...
strcat(): char *strcat( char *str1, const char *str2 );
strcat(str1,str2) concatenates a copy of the string pointed to by str2 to the string pointed to by str1 and terminates str1
with a null
...
The str2 is untouched by the
operation
...
strncat(): char *strncat( char *str1, const char *str2,size_t count );
strncat(str1,str2,n) concatenates not more than n characters of the string pointed to by str2 to the string pointed to
by str1 and terminates str1 with a null
...
The str2 is untouched by the operation
...
The str2 must be a pointer to a null terminated string
...
The str2 must be a pointer to a null terminated string
...
Returns a negative value if str1
...
Returns a negative value if
str1
...
Returns a negative value if
str1
...
Returns a negative value if
str1
...
Returns a
negative value if str1
...
Returns a
negative value if str1
...
quits when the first null character is found
...
strchr(): char *strchr( const char *str, int ch );
strchr(str,ch) finds ch in str
...
strstr(): char *strstr( const char *str1, const char *str2 );
strstr(str1,str2) finds the first occurrence of substring str2 in str1
...
strrev():char *str( char *str);
strrev(str) reverses all characters in str(except for the terminating null )
...
strset(): char *strset( const char *str,char ch );
strset(str,ch) set all character in str to ch
...
Returns a pointer to str
Title: main c language function
Description: required c language function,loop,statement and pointer
Description: required c language function,loop,statement and pointer