0% found this document useful (0 votes)
22 views3 pages

C Programming in One Shot _ Part 1 Notes

This document provides an introductory guide to C programming for beginners, covering essential topics such as basic program structure, variables, data types, input/output functions, and operators. It includes sample problems for practical application and outlines variable naming rules and escape sequences. Additional topics like control statements are previewed for future learning.

Uploaded by

Debasmit Bose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

C Programming in One Shot _ Part 1 Notes

This document provides an introductory guide to C programming for beginners, covering essential topics such as basic program structure, variables, data types, input/output functions, and operators. It includes sample problems for practical application and outlines variable naming rules and escape sequences. Additional topics like control statements are previewed for future learning.

Uploaded by

Debasmit Bose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

C Programming in One Shot | Part 1 Notes

1. Introduction & Prerequisites


Target Audience: First-year students, placement/test aspirants, and absolute beginners in
coding.
Requirements: Laptop/PC (any configuration); optional phone for side-by-side coding;
basic 10th-grade mathematics comfort.
Tools: Online C compiler (e.g., Online GDB) initially; transition to Visual Studio Code for
offline work.

2. “Hello, World!” & Output in C


Basic Program Structure
#include <stdio.h>

int main() {
printf("Hello, World!");
return 0;
}

printf Function

Prints exactly what’s inside double quotes to the output screen.


Requires #include <stdio.h> header to avoid compiler warnings.

3. Escape Sequences
New Line (\n)
Inserts a line break without printing the sequence itself.
Multiple \n give multiple blank lines.
Examples
printf("Line 1\nLine 2\n");

prints:
Line 1
Line 2
4. Variables & Data Types
Concept: Containers to hold values in memory.
Declaration Syntax:
int x;
float radius;
char grade;

Common Types
int (integer)
float/double (floating-point)
char (single character)

5. Input in C
scanf Function

Reads values from user and stores them in variables.


Format specifier must match variable type.

int a;
scanf("%d", &a);

6. Operators & Expressions


Arithmetic Operators: +, -, *, /, %
Operator Precedence:
1. Parentheses ()
2. Multiplication/Division/Modulo
3. Addition/Subtraction
Example
float result = (a + b) * c / d;

7. Sample Problems
1. Volume of a Sphere
float r;
scanf("%f", &r);
float volume = 4.0/3.0 * 3.14159 * r * r * r;
printf("Volume: %.2f", volume);

2. Percentage of 5 Subjects
int m1, m2, m3, m4, m5;
scanf("%d %d %d %d %d", &m1, &m2, &m3, &m4, &m5);
float percentage = (m1 + m2 + m3 + m4 + m5) / 5.0;
printf("Percentage: %.2f%%", percentage);

3. Simple Interest
float P, R, T;
scanf("%f %f %f", &P, &R, &T);
float SI = (P * R * T) / 100;
printf("Simple Interest: %.2f", SI);

8. Character Data Type & ASCII


char holds a single character.
ASCII Values: Each char maps to an integer code (e.g., 'A' = 65).

9. Variable Naming Rules


Must start with a letter or underscore (_).
Can contain letters, digits, and underscores.
Case-sensitive.
No spaces or special symbols.

10. Predict the Output Questions


Trace printf calls and escape sequences step by step.
Escape sequences (e.g., \n) don’t print literally; they change formatting.

11. Additional Topics (Preview)


Control Statements (if, for, while) – covered next lecture.
Short/Long Data Types, further MCQs.
Use this structure to review each section, write down key code snippets, test examples
yourself in an online compiler, and practice “predict the output” problems by dry-running
code.

You might also like