Skip to main content

Posts

Showing posts from February, 2011

Absolute value and Floating-point absolute value function in C Programming Language

Absolute value function in C Programming Language is abs(i), Its return the absolute valu of i. where  i  is any positive or negative  number. It is integer type function. The include file of abs(i) is stslib.h Observe under program: #include<stdio.h> #include<stdlib.h> int main(void) { int a; scanf("%d",&a); printf("%d",abs(a)); } Here I use a integer number. Input it by scanf and print the Absolute value by abs() function. Floating-point Absolute value function in C Programming Language is fabs(i), Its return the absolute valu of i. where  i  is any positive or negative  Floating-point number. It is double integer type function. The include file of fabs(i) is math.h Observe under program: #include<stdio.h> #include<stdlib.h>  int main(void) { float a; scanf("%f",&a); printf("%.2f",fabs(a)); } Here I use a integer number. Input it by scanf and print the Floating-point Absolute value b

Variables in C Programming Language

Variables:   A variable is a named location in memory that is used to hold a value that can modified by a program. The general form of a variable declaration is Variable-type variable –name By the declaration of variables, there are three type Variables; 1.        Loacal 2.        Formal 3.        Global Local Variable:   If a variable declared inside a function called Local Variable. You may called it also Automatic Variable. Condition: 1.        It works in a function or a code block, if you exit form function the local variable destroyed.

Operator in C Programming Language.

Operator:  C has many built in Operator. There are four main operators in c Programming Language. Arithmetic Operator Relational Operator Logical Operator   Bitwise Operator But there are some special Operators, such as Assignment Operator Conditional Operator Unary Operator etc. General form Assignment Operator:   The Operator who assigns a value or expression called Assignment Operator General form of Assignment Operator Variable_name= expression  Single Assignment: If we assign only one variable to a value is called Single Assignment. Example:   X=5; Y=z; etc. Multiple Assignments: If we assign many variable to a value is called Multiple Assignment. Example: x=y=z=5; A=b=c=Pi; etc. Compound Assignment: If we assign a statement to a value is called Compound Assignment. Example: x=y+5; x=x+5; it also can be written as x+=5; x=x-5; it also can be written as x-=5; etc.

Hexadecimal and Octal Constant in C Programming

Octal:   The number system based on 8 is called octal and uses the digits 0 through 7. In octal, the number 15 is the same as 13 in decimal. Hexadecimal:   The base 16 number system is called hexadecimal and uses the digits 0 through 9 plus the letters A through F, which stand for 10, 11, 12, 13, 14, and 15, respectively. For example, the hexadecimal number A is 10 in decimal. It is sometimes more easier to use a number system based on 8 or 16 rather than 10. Because these two number systems are used frequently, C allows usto specify integer constants in hexadecimal or octal instead of decimal. A hexadecimal constant must consist of a Ox followed by the constant in hexadecimal form. An octal constant begins with a 0. Here are two examples: int hex = 0x40;       in Decimal 64 int oct = 040;          in Decimal 32