KEMBAR78
Basic C programming Language - Unit 1.pptx
What is C
• C is a general-purpose, procedural, high-level programming language used in the development of computer
software and applications, system programming, games, and more.
• C language was developed by Dennis M. Ritchie at the Bell Telephone Laboratories in 1972.
• It is a powerful and flexible language which was first developed for the programming of the UNIX operating
System.
• C is one of the most widely used programming languages.
A variable in C language is the name associated with some memory location to store data of different types. There
are many types of variables in C depending on the scope, storage class, lifetime, type of data they store, etc. A
variable is the basic building block of a C program that can be used in expressions as a substitute in place of the
value it stores.
What is a variable in C?
A variable in C is a memory location with some name that helps store some form of data and retrieves it when
required. We can store different types of data in the variable and reuse the same variable for storing some other data
any number of times.
C Variable Syntax
The syntax to declare a variable in C specifies the name and the type of the variable.
data_type variable_name = value; // defining single variable
or
data_type variable_name1, variable_name2; // defining multiple variable
Here,
• data_type: Type of data that a variable can store.
• variable_name: Name of the variable given by the user.
• value: value assigned to the variable by the user.
Data Types in C
Each variable in C has an associated data type. It specifies the type of data that the variable can store like integer,
character, floating, double, etc. Each data type requires different amounts of memory and has some specific
operations which can be performed over it. The data type is a collection of data with values having fixed values,
meaning as well as its characteristics.
The data types in C can be classified as follows:
Type Description
Primitive Data Types Primitive data types are the most basic data types that are used for representing
simple values such as integers, float, characters, etc.
User Defined Data Types The user-defined data types are defined by the user himself.
Derived Types The data types that are derived from the primitive or built-in datatypes are referred to
as Derived Data Types.
Different data types also have different ranges up to which they can store numbers. These ranges may vary from compiler to compiler.
Below is a list of ranges along with the memory requirement and format specifiers on the 32-bit GCC compiler.
Integer Data Type
The integer datatype in C is used to store the integer numbers(any number including positive, negative and zero without
decimal part). Octal values, hexadecimal values, and decimal values can be stored in int data type in C.
Range: -2,147,483,648 to 2,147,483,647
Size: 4 bytes
Format Specifier: %d
Character Data Type
Character data type allows its variable to store only a single character. The size of the character is 1 byte. It is the most
basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers.
Range: (-128 to 127) or (0 to 255)
Size: 1 byte
Format Specifier: %c
Float Data Type
In C programming float data type is used to store floating-point values. Float in C is used to store decimal and
exponential values. It is used to store decimal numbers (numbers with floating point values) with single precision.
Range: 1.2E-38 to 3.4E+38
Size: 4 bytes
Format Specifier: %f
algorithm to find largest among two numbers
Step 1: Start
Step 2: Input the values of A, B Compare A and B.
Step 3: If A > B then go to step 5
Step 4: Print “B is largest” go to Step 6
Step 5: Print “A is largest”
Step 6: Stop
Basic C programming Language - Unit 1.pptx

Basic C programming Language - Unit 1.pptx

  • 1.
    What is C •C is a general-purpose, procedural, high-level programming language used in the development of computer software and applications, system programming, games, and more. • C language was developed by Dennis M. Ritchie at the Bell Telephone Laboratories in 1972. • It is a powerful and flexible language which was first developed for the programming of the UNIX operating System. • C is one of the most widely used programming languages.
  • 2.
    A variable inC language is the name associated with some memory location to store data of different types. There are many types of variables in C depending on the scope, storage class, lifetime, type of data they store, etc. A variable is the basic building block of a C program that can be used in expressions as a substitute in place of the value it stores. What is a variable in C? A variable in C is a memory location with some name that helps store some form of data and retrieves it when required. We can store different types of data in the variable and reuse the same variable for storing some other data any number of times.
  • 3.
    C Variable Syntax Thesyntax to declare a variable in C specifies the name and the type of the variable. data_type variable_name = value; // defining single variable or data_type variable_name1, variable_name2; // defining multiple variable Here, • data_type: Type of data that a variable can store. • variable_name: Name of the variable given by the user. • value: value assigned to the variable by the user.
  • 4.
    Data Types inC Each variable in C has an associated data type. It specifies the type of data that the variable can store like integer, character, floating, double, etc. Each data type requires different amounts of memory and has some specific operations which can be performed over it. The data type is a collection of data with values having fixed values, meaning as well as its characteristics.
  • 5.
    The data typesin C can be classified as follows: Type Description Primitive Data Types Primitive data types are the most basic data types that are used for representing simple values such as integers, float, characters, etc. User Defined Data Types The user-defined data types are defined by the user himself. Derived Types The data types that are derived from the primitive or built-in datatypes are referred to as Derived Data Types.
  • 6.
    Different data typesalso have different ranges up to which they can store numbers. These ranges may vary from compiler to compiler. Below is a list of ranges along with the memory requirement and format specifiers on the 32-bit GCC compiler. Integer Data Type The integer datatype in C is used to store the integer numbers(any number including positive, negative and zero without decimal part). Octal values, hexadecimal values, and decimal values can be stored in int data type in C. Range: -2,147,483,648 to 2,147,483,647 Size: 4 bytes Format Specifier: %d Character Data Type Character data type allows its variable to store only a single character. The size of the character is 1 byte. It is the most basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers. Range: (-128 to 127) or (0 to 255) Size: 1 byte Format Specifier: %c
  • 7.
    Float Data Type InC programming float data type is used to store floating-point values. Float in C is used to store decimal and exponential values. It is used to store decimal numbers (numbers with floating point values) with single precision. Range: 1.2E-38 to 3.4E+38 Size: 4 bytes Format Specifier: %f
  • 15.
    algorithm to findlargest among two numbers Step 1: Start Step 2: Input the values of A, B Compare A and B. Step 3: If A > B then go to step 5 Step 4: Print “B is largest” go to Step 6 Step 5: Print “A is largest” Step 6: Stop