Author: CodeCapsule

C User Input 0

C User Input

1. Basic Input Functions In C, user input is mainly taken using: scanf() → Reads formatted input getchar() → Reads a single character gets() → Reads a string (unsafe, avoid using) fgets() → Reads...

C String Functions 0

C String Functions

1. Include the Header #include <string.h> All standard string functions are defined in <string.h>. 2. Common C String Functions Function Description Example strlen(str) Returns the length of a string (excluding \0) int len =...

C Special Characters 0

C Special Characters

1. What are Special Characters in C? Special characters are prefixed with a backslash \. They are used for newline, tab, quotes, backslash, etc. Mainly used in strings and character constants. 2. Common Special...

C Strings 0

C Strings

1. What is a String in C? In C, a string is an array of characters terminated by a null character \0. The null character \0 marks the end of the string. Example of...

C Multidimensional Arrays 0

C Multidimensional Arrays

1. What is a Multidimensional Array? A multidimensional array is an array of arrays. The most common is a 2D array, which can be thought of as a table with rows and columns. Syntax...

C Arrays – Real-Life Examples 0

C Arrays – Real-Life Examples

1. Storing Marks of Students Suppose you have 5 students and want to store their marks. Instead of creating 5 separate variables, use an array:

  Output: Student 1: 85 marks Student 2:...

C Array Loop 0

C Array Loop

1. Looping Through an Array Using for Loop The most common way to process array elements is with a for loop. Example: Print all elements of an array #include <stdio.h> int main() { int...

C Array Size 0

C Array Size

1. Declaring Array Size When you declare an array, you must specify its size (number of elements): int numbers[5]; // array can hold 5 integers Array size must be a positive integer constant. Example:...

C Arrays 0

C Arrays

1. What is an Array? An array is a collection of elements of the same data type stored at contiguous memory locations. Arrays allow you to store multiple values using a single variable name....

C Break and Continue 0

C Break and Continue

1. What is break? The break statement immediately exits the loop (or switch statement). No further iterations are executed after break. Syntax: for (int i = 1; i <= 10; i++) { if (i...