Introduction to C Programming and HTML
Comments and Their Types
Single-line comments: // This is a single-line comment
Multi-line comments: /* This is a multi-line comment */
Prefix (++n) vs. Postfix (n++) Operators
Prefix (++n): Increments before use
Postfix (n++): Uses value first, then increments
Basic Structure of a C Program
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
Top-Level Domain (TLD) in URL
The last part of a domain name (e.g., .com, .org, .edu)
Variables and Rules for Declaring Them
Valid: age, total_marks
Invalid: 2total, my-variable
Rules: Must begin with a letter or _; No special characters except _; Case-sensitive
IDE in Programming
An IDE includes an Editor, Compiler, and Debugger.
Loops in C
Pre-test loops: for, while
Post-test loop: do-while
Criteria for Best Solution
Speed: Faster execution
Cost: Less memory usage
Complexity: Easier to understand
Source Code vs. Object Code
Source code: Written by the programmer
Object code: Compiled machine code
Modular Programming & Advantages
Breaking a program into smaller functions for reusability and maintenance.
Operator Precedence in C
* / % have higher precedence than + -
Parentheses () override precedence
= vs. == Operator
= is assignment
== is comparison
scanf() vs. printf()
scanf() takes input
printf() displays output
while vs. do-while Loop
while checks condition before execution
do-while executes at least once
Control Structures & Types
1. Sequential
2. Selection (if, switch)
3. Iteration (for, while)
URL, WWW, and HTML
URL: Web address
WWW: World Wide Web
HTML: Markup language
Typecasting in C
Implicit: Automatically converted
Explicit: Manually converted using (type)
Relational & Logical Operators
Relational: >, <, >=, <=, ==, !=
Logical: &&, ||, !
Format Specifiers in C
%d: Integer
%f: Float
%c: Character
%s: String
Escape Sequences
\n: Newline
\t: Tab
Loops (for to while)
for (int i = 0; i < 5; i++) { printf("%d ", i); }
Equivalent while loop:
int i = 0; while (i < 5) { printf("%d ", i); i++; }
if-else to switch
if (x == 1) printf("One");
else if (x == 2) printf("Two");
Equivalent switch:
switch (x) { case 1: printf("One"); break; case 2: printf("Two"); break; }
#define vs. const
#define PI 3.14
const int a = 10;
getch() vs. getche()
getch() takes input without displaying
getche() displays input
switch Statement Example
switch (choice) { case 1: printf("One"); break; case 2: printf("Two"); break; }
break & continue
break: Exits loop
continue: Skips current iteration
Syntax vs. Semantics
Syntax: Structure of code
Semantics: Meaning of code
Interpreter vs. Compiler
Interpreter executes line-by-line
Compiler converts entire code at once
Preprocessor Directives
#include <stdio.h> (Includes library)
#define MAX 100 (Defines constant)
Reserved Words (Keywords)
Examples: int, float, return, void
Types of Lists in HTML
Ordered (<ol>), Unordered (<ul>), Definition (<dl>)
Changing Background Color in HTML
<body style="background-color:lightblue;">
Creating a Table in HTML
<table border="1"><tr><td>Row1</td></tr></table>