Posts

2.1 Control statements in C programming (sequential & conditional)

Image
Control statements in C: - C is a structure-orientated programming language; the statements that are used to control the flow of execution of a program are called control structures. The statements provide a specific order to execute the C program. In C programming, we have four types of control structures. Sequential control structures Conditional control structures Iterative control structures Jumping control structures   1) Sequential control structures: - The C program is a collection of instructions or set of statements which are executed sequentially in a user-specific order. No statement is slipped, and no statement is executed more than once.                   Syntax: -                Flow chart: -                Example: - Output: - 1) Conditional control structures: - It is also known as selection, branchi...

Type conversion in expression in c

Image
Type conversion in expressions: - Type conversion is a process of converting a variable's value from one data type to another data type. There are two main types of conversion in C:                    1.  Implicit type conversion.                    2.  Explicit type conversion.   1) Implicit type conversion: -   Implicit type conversion is a process of converting a variable's value from the lowest size of data type to the highest size of another data type. This conversion is automatically done by the compiler without user intervention. It is also known as type promotion or implicit type casting or automatic type conversion. Hierarchy of data types:                  Example: -                Output: -  2) Explicit type conversion: - Explicit type ...

Expression evaluation, operator precedence, associativity

Image
Expression: - An expression is a sequence of one or more operands (like variables, constants, and function calls) and operators that the compiler evaluates to produce a single value.                  Examples of Expressions in C:                       Constant expression                    :                             45                       Variable expression                     :           ...

3.4 creating tables in MYSQL

Image
  v   Creating Tables: - Ø For creating tables, ·       Import mysql.connector. ·       Connect to MySQL database using connect( ) method. ·       Create a cursor( ) object then pass SQL command of table as a string to the execute( ) method. Ø The SQL command to create table in database with python code is:       Example: - Output: - Ø             First open database using “ use database_name; ” command. Ø   We can check if the table exists in database system or not, by using “ show tables ” command. Ø   To view the structure of table, we use “describe table_name” command.

3.3 creating database in MYSQL

Image
  v   Creating Database: - Ø To create a database in MySQL, first we should connect to MySQL server and create a cursor( ) object then pass SQL command as a string to the execute( ) method. Ø The SQL command to create database with python code is: Example: - Output: - Ø   We can check if a database exists in the system or not , by using the “ show databases ” command.

3.2 Steps to Install MYSQL driver and connecting MySQL server

Image
  v   Steps to Install MYSQL driver and connecting MySQL server: - Ø Python can interact with MySQL using connectors (libraries). Ø The most commonly used library is: mysql-connector-python. Ø To install MySQL driver, type this following command in command prompt.   Py -m pip install mysql-connector-python   Ø To test if the installation was successful, use following command in python IDLE.     Ø To connect with MySQL server, we can use connect( ) method. Ø The sample format code in python is       syntax: - example: -   Output: -   Ø   The default tables in MySQL are: