Posts

Showing posts with the label complete c programming tutorial

Operators in C Language| Part-4

Unary operators Unary operator are those which only require one operand(argument) to operate. + , - , ++, --, typecast and sizeof are some unary operators in C programming. +5, -5 are the example of +,- unary operators. which represents +ve and -ve values. Unary operators have high priority than binary operators, so unary operators are always evalutes first. Increment / Decrement operator ++, -- are called increment and decrement operators. Increment and decrement operators are available in two versions Prefix Postfix Difference b/w prefix and postfix Prefix Postfix int a = 5; ++a; printf("%d",a); // 6 int a = 5; a++; printf("%d",a); // 6 int a = 5,b; b = ++a; printf("%d %d",a,b);// 6 6 int a = 5,b; b = a++; printf("%d %d",a,b);//6 5 Example of increment and decrement operators Example-1: int a = 3, b = 4,c; c = ++a * ++b; printf("%d %d %d",a,b,c); /

Operators in C Language

Image
Observe the given expression y = x + 5. In the above given expression +, = are the operators and x, y, 5 are called operands / argument. Types of operator According to the required argument the operator can be classified into 3 categories: unary operator: require only one argument. example(-5) binary operator: require two argument. example(5+8) ternary operator: require 3 argument. example(?:) According to the purpose operator are again classified into 8 types: Arithmetic operator Unary operator Assignment operator Relational operator Logical operator Bitwise operator Conditional operator(ternary operator) Comma operator Arithmetic operator +,-,*,/,%(mod) are called the arithmetic operator. The +,-,* are same as you learn in mathematical Arithmetic. To more understand take an example. 5 + 3 * 4 In the above given expression, which operator should be evaluates first? As in mathematics you learn the rule of BODMAS,which tells first brackets should be ev

Data types in C language

Image
What is data type As you have seen in the previous article, a variable is declared as given below... int a; //variable declaration In the above program code snippet, int is called a data type and a is a variable of that data type. Data type describe the content a variable can store. Data type also explains how data will be stored (the organization) in memory. Data types can be classified into two broad categories... Primitive (Basic) data type Composite (Secondary) data types / User-defined data types In this article we will only discuss primitive data types, User-defined data types will be discussed later. Primitive data types Data types which are defined by the system/programming language are called primitive data type. These data type defines a single entity, which can't be divided further. List of primitive data types along with their memory occupied and the allowed range are described as below... Integral data types Real data types Character da

Variable in C programming

What is variable? Variable is an entity which can change during the program execution. OR Variable is the name of the memory place, where data is stored. OR Variable is just like a cup of tea . How to create a variable int x; float y; char z; General Syntax datatype variable_name; As shown in the above snippet, To create a variable two things are needed... Data type Variable name Rules for creating variable name Variable name can contains Alphabets(A-Z / a-z), Digits (0-9), and Underscore (_). Variable name must begins with an Alphabet or Underscore Spaces and Special symbols are not allowed. Keywords / Reserved words are not allowed as a variable name. Variable name should be meaningful. C is a case sensitive programming language, so age, Age, AGE all are different variables. Some valid / invalid variable names are listed below... Variable name Valid / Invalid name valid father_name valid father's name

Constant in C Programming

Constant is an entity which never changes in the given problem or program. Types of Constant There are basically two types of constants in C. Scalar/ Primitive/ Primary Composite The Scalar types of constant are those which can't be divided any more and the composite constant are those which can be divided into multiple scalar constants. In this article, we only discuss the Scalar/Primitive constant. The Composite constants are discussed later. 1. Integer Constant A number without any fractional part is called Integer constant. Example: 25, 0, -44, 456 etc Rules of Integer Constant No decimal points are allowed. Example 25 is correct but 25.0 is incorrect. Rules of Integer Constant +ve/-ve both types of values are allowed. Special, Comma and other characters are not allowed. Example 2 3 4 and 12,500 are incorrect. Valid Range: -32768 to 32767 2. Floating point constant or real constant Can contain decimal point +ve/-ve both types of values are allo

Constant and Variable

y = x + 5, See the expression carefully. It is clear that if we change the value of x the value of y is also changed but the 5 remains the same every time. So, x and y are the variables but 5 is a constant. Previous Back to C Programming index Next

Keywords in C language

Keywords are some words, which meaning is already reserved by the compiler. So these words are also called reserved words. In C, there are 32 keywords as listed below. auto double int struct break else long switch case enum register typedef char extern return unsigned const float short union continue for signed void default goto sizeof volatile do if static while Previous Back to C Programming index Next

Character Set

The allowed set of characters is called the character set. C character set consist of the following character. Alphabets A-Z , a-z Digits 0 - 9 White Spaces Spaces, tabs, newlines etc. Special Symbols +, -, *, /, %, _,; and many more discussed as needed. Previous Back to C Programming index Next

Steps of learning C Programming

Steps of learning English Alphabets => Words => Sentence => Paragraph Steps of learning C language Character Set => Keywords/ Constant/ Variable => Instruction => Program Previous Back to C Programming index Next

Why C language used

Influences C Programming Language The question is very simple before learning the C. That is why we learn C? C is very simple, small and fast. C is a programming language which has only 32 words with them you can build your own programming code. Compare to other programming languages the c program executes very fast. The most popular languages derived from C Programming such as C++, Java, C#(C sharp), PHP, Objective-C, Go lang, Python and many more. So if you want to learn those languages the C provide the basic foundation. The most popular operating systems such as Windows, Unix, Linux build with C. So sometimes people say that C is very old and now it is not used. Then I have to say, it is not the truth. Gaming environments are also written in C. More correctly we can say it has an indirect relationship with C. C programming offers better interaction with hardware. Previous Back to C Programming index Next

Printing in C programming

Image
Printing in C In C for printing purpose, We Use A Function Called printf( ) . A function is a small program used to perform a specific task. The function receives some input known as an argument and produces some output called return value. Functions are always suffixed with parenthesis ( ). Syntax of printf( ) printf("Control String",[List or Variable]); Note: Control string is a sequence of characters which you want to print. ([ ]) square brackets around the list or variable represent that it is optimal. Example Of printf( ) printf("hello"); //Print hello int a=5,b=6; printf("a=%d b=%d",a,b); //print the value of a and b. int a=5,b=6; //Varialbe Declaration printf("%d",a+b); //Print 11. Note: In printf( ) expression can be written .The example is given above. The first program, Say Hello World in C programming /*program to print the "Hello world"*/ #include<stdio.h> int main() { printf(

History of C programming language

History of C C is a general-purpose programming language initially developed by the  Dennis Ritchie  between 1969 to 1973 at AT & T (American Telegraph and telecommunication) Bell Labs. It is named  C  because its features are derived from the earlier language called  B  which is developed by the  Ken Thomson . According to Ken Thomson  B  was the stripped-down version of BCPL (Basic combined programming Language). The origin of c is closely tied up with the Unix operating system development. In 1973 with the addition of  struct  type the c becomes powerful enough that the Unix operating system was designed in C. This was one of the first operating system kernels implemented in a language other than assembly. In 1978, Brian Kernighan and Dennis Ritchie published the first edition of  The C Programming Language. This book, known to C programmers as "K&R", served for many years as an informal specification of the language. The vers

Popular posts from this blog

String in golang

Inline V/S Block Level Element

Arrays in C Language

Data Types in Go language

Printing in C programming

Variable Naming & Scope of Variable

Escape Sequence | Formatted Printing | Interview Questions

Floating point Data types in Go lang

Overview of Go lang

Literals in Java