Posts

Showing posts from January, 2024

Variables in C

A variable is a symbolic name that refers to a location in memory where data is stored. It can be used for various purposes and its value can be changed. It is a way of using symbols to identify memory locations so that they can be accessed and manipulated more conveniently. Type variable_list; The example of declaring the variable is given below:int a; float b; char c; Here a, b, c are variables. The int, float, char are the data types. Alternatively, we can assign values to the variables when we declare them, as shown below: int a=10,b=20;//declaring 2 variable of integer type float f=20.8; char c='A'; Rules for defining variables A variable is a name that can consist of letters, numbers, and underscores.  A variable name must begin with a letter or an underscore, not a number.  A variable name cannot contain any spaces.  A variable name cannot be the same as any of the reserved words or keywords in the programming language, such as int, float, etc.

printf() and scanf() in C

In C language, input and output operations are performed by the functions printf() and scanf(), which are built-in library functions defined in the header file stdio.h.

First C Program

Image
Before starting the abcd of C language, you need to learn how to write, compile and run the first c program. To write the first c program, open the C console and write the following code: #include <stdio.h> :-includes the standard input output library functions. The printf() function is defined in stdio.h . int main() :-The main() function is the entry point of every program in c language. printf() :-The printf() function is used to print data on the console. return 0 :-The return 0 statement, returns execution status to the OS. The 0 value is used for successful execution and 1 for unsuccessful execution. You will see the following output on user screen.

Compilation process in c

Image
   What is a compilation?        C is a programming language that converts source code into object code or machine code. The conversion process has four steps: Pre-processing, Compiling, Assembling, and Linking.      The preprocessor eliminates all the comments from the source code and carries out the preprocessor directives. For instance, it substitutes the directive <stdio.h> with the contents of the 'stdio.h' file.       The following are the phases through which our program passes before being transformed into an executable form:         Preprocessor         Compiler         Assembler         Linker Preprocessor A source code file is a text file that contains instructions written in the C programming language. The file name has a ".c" extension to indicate its format. Before compiling the source code, a preprocessor analyzes and modifies it according to certain directives. The preprocessor then passes the expanded code to the compiler, which translates it in

Introduction To C

Image
Dennis Ritchie C programming is considered as the base for other programming languages, that is why it is known as mother language . Because most compilers, JVMs, kernels, etc. are written in C, and because most programming languages (such C++, Java, C#, etc.) adopt C syntax, C language is regarded as the mother tongue of all current programming languages. It offers the fundamental ideas used in numerous languages, including C++, Java, C#, and others, such as the array, strings, functions, file management, etc. C programming language  was developed in 1972 by  Dennis Ritchie  at bell laboratories of AT&T (American Telephone & Telegraph), located in the U.S.A. It was developed to overcome the problems of previous languages such as B, BCPL, etc. Initially, C language was developed to be used in UNIX operating system. It inherits many features of previous languages such as B and BCPL. Let's see the programming languages that were developed before C language. Lan