Posts

Showing posts with the label C language

Important questions in c language 2units

Functions in c

C Functions Interactive Learning Functions in C - Interactive Learning 1. What is a Function? A function is a block of code that performs a specific task. Functions help in code reusability and better structure. 2. Function Declaration (Prototype) Syntax: return_type function_name(parameters); Example: int add(int a, int b); 3. Function Definition Syntax: return_type function_name(parameters) { // body of the function return value; } Example: int add(int a, int b) { return a + b; } 4. Function Call Syntax: function_name(arguments); Example: #include <stdio.h> int add(int, int); int main() { int result = add(5, 10); printf("Sum = %d", result); return 0; } 5. Built-in (Library) Functions These are pre-defined functions in header files. Examples: ...

ARRAYS IN C

Image
Array Concept in C Array Concept in C Understanding Arrays with Examples, Memory Representation, and Operations 📌 What is an Array? An array is a collection of similar data types stored in contiguous memory locations. It allows storing multiple values under a single name, and each value is accessed using an index. int a[5]; // array of 5 integers ⭐ Features of Arrays Stores multiple values of the same data type. Memory is allocated contiguously. Access using an index (starts from 0). Provides random access to elements. Fixed size (decided at compile time). 📝 Declaration & Initialization int marks[5]; int marks[5] = {10, 20, 30, 40, 50}; int marks[] = {10, 20, 30, 40, 50}; ➡️ Accessing Elements printf("%d", marks[0]); // 10 printf(...

Looping statements in c

Looping Statements in C 🔁 Looping Statements in C Loops allow repeating code multiple times until a condition is satisfied. 1️⃣ for Loop 📘 Full Definition The for loop is used when the number of iterations is known in advance. It combines initialization, condition, and increment/decrement in a single line. ⚡ Shortcut: Best for fixed repetitions. 🔹 Syntax: for(initialization; condition; update) { // code to execute } Show Example #include <stdio.h> int main() { for (int i = 1; i 2️⃣ while Loop 📘 Full Definition The while loop is used when the number of iterations is not known in advance. It keeps executing as long as the condition is true. ⚡ Shortcut: Repeat while condition is true. 🔹 Syntax: while(condition) { // code to execute } ...

Conditional statements in C

Conditional Statements in C ✨ Conditional Statements in C Conditional statements help control the flow of a program based on conditions. 1️⃣ if Statement 📘 Full Definition The if statement in C is used to execute a block of code only when a given condition is true. If the condition evaluates to false, the code inside the if block is skipped. ⚡ Shortcut Definition if = Runs code only when condition is true. 📝 Syntax if (condition) { // statements; } Show Example #include <stdio.h> int main() { int age = 18; if (age >= 18) { printf("You are eligible to vote."); } return 0; } 2️⃣ if-else Statement 📘 Full Definition The if-else statement provides two alternative paths of execution. If the condition is true,...

C syllabus for beginners

Image
C Language Syllabus 📘 C Language Syllabus Outline Unit 1: Introduction to C History and Importance of C Structure of a C Program Compilation and Execution Process printf() and scanf() Functions Simple C Programs (Hello World, Sum of Numbers) Unit 2: Operators and Expressions Arithmetic Operators Relational Operators Logical Operators Bitwise Operators Assignment Operators Increment/Decrement Operators Conditional (Ternary) Operator Operator Precedence and Associativity Unit 3: Control Structures if, if-else, nested if-else switch-case statement for loop while loop do-while loop break and continue goto statement Unit 4: Functions in C Definition and Declaration Types of Func...

Operators and expressions

Operators and Expressions in C In C language, operators are special symbols used to perform operations on data and variables. An expression is a combination of operators and operands (variables/constants) that produces a result. Example: a + b is an expression where + is an operator and a , b are operands. 1. Arithmetic Operators These operators are used for mathematical calculations like addition, subtraction, multiplication, etc. Operators: + (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus) #include <stdio.h> int main() {   int a = 10, b = 3;   printf("a+b = %d\\n", a+b);   printf("a-b = %d\\n", a-b);   printf("a*b = %d\\n", a*b);   printf("a/b = %d\\n", a/b);   printf("a%%b = %d\\n", a%b);   return 0; } Output: a+b = 13 a-b = 7 a*b = 30 a/b = 3 a%b = 1 2. Relational Operators These operators are used to co...
C Language Tutorial - Introduction & Basics 🌟 C Language Tutorial for Beginners Welcome! In this tutorial, we’ll learn the basics of C programming step by step with examples and outputs. 1. Introduction to C C is a general-purpose, procedural programming language developed by Dennis Ritchie in 1972 at Bell Labs. It is widely used for system software, operating systems, and embedded programming. ✨ Features of C Simple and powerful Portable (can run on different machines) Structured programming language Fast execution (close to machine language) Base for modern languages like C++, Java, and Python 📌 Structure of a C Program A C program generally follows this structure: #include <stdio.h> // Preprocessor directive int main() { // Main function // Statements return 0; // Exit status } 🔹 Example: Hello World Program ...

C LANGUAGE

C Language – Inventory & Versions 🌟 C Language – Inventory & Versions This page covers the history, versions, syntax, data types, variables, constants, and operators in C with examples. 1. Inventory (History & Origin) Year Event 1969–1972 Developed by Dennis Ritchie at Bell Labs as a system programming language for UNIX. 1978 K&R C (first edition of The C Programming Language book published). 1989 ANSI C (C89) standard approved by ANSI. 1990 ISO C (C90) standardized internationally. 1999 C99 update introduced inline functions, variable-length arrays, // comments, and more. 2011 C11 introduced multi-threading support, Unicode handling, bounds-checking functions. 2018 C18 (minor revision of C11) — bug fixes and clarifications. 2. Why Use C? Foundation of programming – base for languages like C++, Java, C#. System-level programming – OS, compilers,...