Posts

parameters, parameter passing in function

parameters, parameter passing in function In function parameters are those that we pass in function. parameters are decided when the function is created, the parameters passing

String Functions

String Functions Function Use strlen Finds length of a string strlwr Converts a string to lowercase strupr Converts a string to uppercase strcat Appends one string at the end of another strncat Appends first n characters of a string at the end of another strcpy Copies a string into another strncpy Copies first n characters of one string into another strcmp Compares two strings strncmp Compares first n characters of two strings strcmpi Compares two strings without regard to case ("i" denotes that this function ignores case) stricmp Compares two strings without regard to case (identical to strcmpi) strnicmp C...

Precedence And Associativity In C

Operators precedence: It defines the order of evaluation of operators in an expression. Associativity defines the order in which operators of the same precedence are evaluated in an expression. Associativity can be either left to right or right to left. Operator precedent example: 10 + 20 * 30 Now here addition operator has lower precedence and multiplication operator has higher precedence, there for the multiplication operator evaluate first and our equation became 10 + 60 is equal to 70 Here 10+20*30 is calculated as 10+(20*30) is equal to 70 Operator Associativity: Example: '*' and '/' have the same precedence and their associativity is left to right. 100/10*10 is evaluated as (100/10)*10 here / and * have the same precedence but left to right associativity so division operator evaluate first because it comes first from the left side and then the multiplication operator is evaluated 100/10  *10 10* 10 100 Example: 100 + 100/10 - 2 *10 will be evaluated as follows Ste...

Functions In C

    function initialization / definition: here we define your functions with its entire logic. If we defied the prototype of the function then the function definition always defined after defining the prototype of the function. syntax: returntype_of_function  function_name( arguments...){ //entire logic; // return value; } example: int sum( int a, int b){ int x; x=a+b; return x; } Here, In your example, we first define your function definition as int sum( int a, int b) here we write return type as int because at the end the function is going to return an integer value  ( x ). Then we write name of the function as a sum and in parentheses, we specified arguments as int a and int b . That means your function is going to tack two arguments of integer type when we are calling the function. More example on functions: Recursion: recursion means function calling it self. when function call it self in function definition it called as resursion. example of recursive function: fac...

prototype of function

prototype of function: prototype of the function is just the basic format of function, in the prototype we just decide datatype of function according to the return type of function and which type data type's and how many arguments is going to take when we want to execute the function. Simply, the prototype is a blueprint of your function. we put all prototype at top of code before the declaration of all functions including the main function because when the code is compiled the prototype is gives promise to the compiler that the function is declared anywhere in the program. Don't worry if you don't get it, its became more clear with an example. syntax: ReturnType Function_Name(argument1, argument2, argument3 , ...) Examples: int max(int a,int b,int c); void mul( float x, float y ); View this gist on GitHub

Introduction to Function in C

Functions In C programming language, the user just needs to call the function whenever the user wants to use the function. The example of system-defined functions are printf( ),scanf( ),getsThe functions are known as giving some output for one particular input or argument, we already work with functions like main( ), printf( ),scanf( ) in your  c programs. functions in C are use full in case of reducing code, to improve readability and reuse of code. If we want to perform a certain task frequently with different-different values or parameters then the use of function is convenient for us. It helps to reduce, reuse and improve the readability of your program. there are two types of functions system-defined functions user-defined functions system-defined functions: system-defined functions are already defined by the ( ),puts( ),pow( )... that are already defined by the system we just need to include the file/library that contains the function declaration for...

recursion examples

example: Factorial of number:

Recursion

Recursion: recursion means function calling it self. when function call it self in function definition it called as recursion. example of recursive function: factorial of number Fibonacci series marge and quick sort And many more... lets understand recursion with example: To understand recursion well lets understand first about stack stack: stack is used to store value and for that stack follows certain rules as LIFO or FILO mean whatever last value is stored it give that value fist ( last in first out) and value that stored first it given at last( first in first out ) both are same in logic way. Don't worry if you face any problem to understand stack it become more clear when we refer examples.  

Header Files

Header Files Header Files are already written files that simplify your work for example for i/o we have stdio.h header file by using that we can simply input and output stuff to the console. header files have .h extension with it and it is one of the example of modularity of c language, there are many header files are available in c language. stdio.h   defines core input output functions string.h  defines string handling function math.h  defines common mathematical functions and many more... To use these header files, first  we include them in your program and then we can start using their features syntax: #include <headder_filename.h> OR #include "header_filename.h"

indeterminate forms

  types of indeterminate forms:    [latex]\frac00[/latex]    [latex] \frac\infty\infty [/latex]    [latex] 0\;\times\infty [/latex]    [latex] \infty-\infty [/latex]    [latex] 1^\infty [/latex]    [latex] 0^0[/latex]    [latex] \infty^\infty [/latex] This all types of limits can be evaluated by using the L' Hospital's rule.   L' Hospital's rule If f(x) and g(x) are two function of x which can be expanded by Taylor's series in the neighborhood of x = a and if  [latex] \lim_{x\rightarrow a}f\left(x\right)=f\left(a\right)=0 [/latex],  [latex] \lim_{x\rightarrow a}g\left(x\right)=g\left(a\right)=0 [/latex], then [latex]\lim_{x\rightarrow a}\frac{f\left(x\right)}{g\left(x\right)}=\lim_{x\rightarrow a}\frac{f'\left(x\right)}{g'\left(x\right)}[/latex]   formulas: [latex]\lim_{x\rightarrow 0}\frac{\sin x}x=1[/latex]