PropellerAds

Mathematical Functions In C language

No comments :

FUNCTIONS  In c Language

A function is a self-contained block of code that performs a particular task. Once a function has been designed and packed, it can be treated as a ’black box’ that takes some data from the main program and returns a value. The inner details of operation are invisible to the rest of the program. All that program knows about a function is: what goes in and what comes out. Every program can be designed using a collection of these black boxes known as functions. 

The Mathematical Functions: The mathematical functions are divided into following categories: 
(1) Trigonometric functions 
(2) Hyperbolic functions.
(3) Exponential and logarithmic functions. 
(4) Miscellaneous functions. 
All the math functions require the header file <cmath> or <math.h>  1)Trigonometric Functions:
(i) cos(): The cos() function returns the cosine of the argument passed to it. The value of the argument must be in radians.
Syntax: float cos(float); 
double cos(double);
long double cos(long double);
(ii) sin(): The sin() function returns the sine of the argument passed to it. The value of argument must be in radians.
Syntax: float sin (float); 
double sin (double); 
long double sin (long double);
(iii) tan(): The tan() function returns the tangent of the argument passed to it. The value of argument must be in radians.
Syntax: float tan (float); 
double tan (double);
long double tan (long double);

(iv) acos(): The acos() function returns the arc cosine of the argumet passed to it. The argument to acos() must be in the range -1 to 1; Otherwise a domam error will occur. 

Syntax: float acos (float);
double acos (double); 
long double acos (long double); 

(v) asin: The asin() function returns the arc sine of the argument passed to it. The argument to asin() must be in the range of -1 to 1; otherwise a domain error will occur. 

Syntax: float asin (float); 
double asin (double); 
long double asin (long double);


(vi) atan(): The atan() function returns the arc tangent of the argument passed to it. 
Syntax: float atan (float); 
double atan (double); 
long double atan (long double); 

(Vii)atan2(): The atan2() function returns the arc tangent of y/x. It uses the signs of its arguments to compute the quadrant of the return value. Syntax: 

float atan2 (float, float); 
double atan2 (double, double); 
long double atan2 (long double, long double); 



Program Development cycle In C langauage

No comments :
Program Development cycle
Program Development cycle In C langauage


  1. Problem Definition: In this phase, we define the problem statement and we decide the boundaries of the problem. In this phase we need to understand the problem statement, What is our requirement, what should be the output of the problem solution? These are defined in this first phase of the program development life cycle. 
  1. Problem Analysis: In phase 2, we determine the requirements like variables, functions, etc. to solve the problem. That means we gather the required resources to solve the problem defined in the problem definition phase. We also determine the bounds of the solution. 
  1. Algorithm Development: During this phase, we develop a step by step procedure to solve the problem using the specification given in the previous phase. This phase is very important for program development. That means 'we write the solution in step by step statements. 
  1. Coding 8: Documentation: This phase uses a programming language to write or implement actual programming instructions for the steps defined in the previous phase. In this phase, we construct actual program. That means we write the program to solve the given problem using programming languages like C, C++, Java etc.,
  1. Testing 8: Debugging: During this phase, we check whether the code written in previous step is solving the specified problem or not. That means we test the . program whether it is solving the problem for various input data values or not. We also test that whether it is providing the desired output or not. 
  1. Maintenance: During this phase, the program is actively used by the users. ‘If any enhancements found in this phase, all the phases are to be repeated again to make

How to write a program in C to find the root of a Quadratic Equation

No comments :

How to write a program in C to find the root of a Quadratic Equation

In this example the value of a,b,c are given we have to just put formula
You can do this problem via accepting values of a,b,c from user and then show the final output
CODE-

#include<stdio.h>

int main()

{

int a=5,b=10,c=15,root,x,y;

   root=(b*b-4*a*c);

    x=(-b+root)/(2*a);

    y=(-b-root)/(2*a);

    printf("\n quadratic equation is %d and %d",x,y);

    

}


Output





In case where user have to enter the value of the a,b,c variables then write the following code before the formula


And  the output will come according the value entered by user

Functions In C

No comments :

FUNCTIONS  In c Language

A function is a self-contained block of code that performs a particular task. Once a function has been designed and packed, it can be treated as a ’black box’ that takes some data from the main program and returns a value. The inner details of operation are invisible to the rest of the program. All that program knows about a function is: what goes in and what comes out. Every program can be designed using a collection of these black boxes known as functions. 


C functions can be classified into two categories: 

(i) Library functions or Built-in functions, and(ii) User-defined functions. 


Main is an example of user-defined functions. The distinction between these two categories is that library functions are not written by us whereas a user-defined function has to be developed by the user at the time of writing a program. However, a user defined function can later become a part of the C program library.
Every program in C must have a main function to indicate where the program has to begin its execution. While it is possible to code any program utilizing only main function, it leads to a number of problems. The program may become too large and complex and as a result the task of debugging, testing, and maintaining becomes difficult. If a program is divided into functional parts, then each part may be independently coded and later combined into a single unit. These subprograms called ’functions’ are much easier to understand, debug, and test.
There are times when certain type of operations or calculations is repeated at many points throughout a program. For instance, we might use the perfect square of a number at several points in the program. In such situations, we may repeat the program statements wherever they are needed. Another approach is to design a function that can be called and used whenever required. This saves both time and space.
This division has a number of advantages:
It facilitates the top-down modular programming. In this programming style, the
high level logic of the overall problem is solved first while the details of each lower-level function are addressed later.
Types of Function

  • Predefined Standard Library Functions
Such as Put(),gets(), printf(),scanf(),etc. these are  already Predefined in Header files, we just call them whenever their  requirement.

  • User Defined Functions
The Functions that we create.

syntax for Function - return_type Function_name(argument list)
{
Set of Statements
}

Creating  User defined functions 
we will solve A example where we define Functions to ADD two numbers
Declaration





  • num1 and num2   (use to add number)

    • sum=num1+num2 (formula for addition)
    User defined function In C




    OUTPUT




    see other program examples for better understanding 













































































    Draw A Flowchart and Algorithm to find the Factorial of A number

    No comments :

    Draw A Flowchart and Algorithm to find the Factorial of A number

    we will draw Flowchart and Algorithm to find  the factorial of number .

    DECLARATIONS- 
    • fact=factorial
    • num= number that we  accept from user as input.
    • (fact*=n
    • n++) formula to find factorial

    Algorithm

    Step 1:Start
    Step 2:Declare variables n=1,fact=1,num
    Step 3:Read variables num
    Step 4: fact*=n , n++
    Step 5: If n<num
    Step 6:Display fact
    Step 7:Stop


    Flowchart

    How to draw a flowchart & Algorithm to display odd and even number in c language

    No comments :

    How to draw a flowchart to  display odd and even number in c language





    Note- there was a mistake in above Image (N%2=0)

    Algorithm to show odd and even number in C language

    step 1: start
    Step 2:declare variables N
    Step 3:read variables 
    Step 4:if N%2=0
    Step 5:display N is even number
    Step 6:if N%2!=0
    Step 6:dispaly N is odd
    Step 7: stop

    How to draw a flowchart to display positive or negative number in c

    No comments :

    How to draw a flowchart to display odd or even number in c





































    Algorithm
    step1: start
    step2: Declare variables N
    Step3: read variables N
    step4:if N>0
    step5: display N is positive
    step6: else
    step7: display N is negative
    step8:stop