Part 2 | Variables Datatypes & I/O Operations | C Programming Malayalam Tutorial
Table of Contents
Introduction
This tutorial focuses on understanding variables, data types, and input/output operations in C programming. By the end of this guide, you'll have a foundational knowledge of how to declare and use different data types, handle user input, and output results to the console.
Step 1: Understanding Programming Basics
- Definition of Programming: Programming involves creating a set of instructions that a computer can execute. It enables you to perform tasks and manipulate data.
- Console Output: Utilize the
printf
function to display messages or results on the console.
Step 2: Working with Variables
- What is a Variable: A variable is a named storage location in memory that can hold a value.
- Declaration: To declare a variable, specify the data type followed by the variable name.
int age; // Declaration of an integer variable float salary; // Declaration of a float variable char grade; // Declaration of a character variable
Step 3: Exploring Data Types
- Integer: Used to store whole numbers.
- Float: Used to store decimal numbers.
- Character: Used to store single characters.
Practical Tip
Choose the right data type based on the nature of the data you need to store. This affects memory usage and the precision of the values.
Step 4: Variable Initialization
- Initialization: Assign a value to a variable at the time of declaration.
int age = 25; // Initializing an integer variable float salary = 50000.50; // Initializing a float variable char grade = 'A'; // Initializing a character variable
Step 5: Input Operations
- Using scanf for Input: Utilize the
scanf
function to read user input.scanf("%d", &age); // Reading an integer input scanf("%f", &salary); // Reading a float input scanf(" %c", &grade); // Reading a character input
Step 6: Performing Calculations
- Basic Operators: Understand how to use operators for calculations.
- Arithmetic Operators: +, -, *, /, %
- Relational Operators: ==, !=, >, <, >=, <=
- Logical Operators: &&, ||, !
- Assignment Operators: =, +=, -=, etc.
Step 7: Example Code for Summation
Here’s a simple example demonstrating the use of variables and input/output operations:
#include <stdio.h>
int main() {
int num1, num2, sum;
printf("Enter two integers: ");
scanf("%d %d", &num1, &num2);
sum = num1 + num2;
printf("Sum: %d\n", sum);
return 0;
}
Conclusion
In this tutorial, you learned about the core concepts of variables, data types, and basic input/output operations in C programming. To further enhance your skills, practice writing simple programs using these concepts. Experiment with different data types and operators to see how they work in various scenarios. Continue exploring programming through additional tutorials and hands-on projects.