0% found this document useful (0 votes)
2 views2 pages

C Language Programming Basics Guide

The document provides an overview of the C programming language, including its history, structure, basic elements, and key features. It covers essential topics such as input/output, operators, control statements, loops, arrays, strings, functions, pointers, structures, and file handling. The content serves as a foundational guide for understanding and programming in C.

Uploaded by

choyalraj51
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)
2 views2 pages

C Language Programming Basics Guide

The document provides an overview of the C programming language, including its history, structure, basic elements, and key features. It covers essential topics such as input/output, operators, control statements, loops, arrays, strings, functions, pointers, structures, and file handling. The content serves as a foundational guide for understanding and programming in C.

Uploaded by

choyalraj51
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

■ C Language Notes

1. Introduction to C
- Developed by Dennis Ritchie at Bell Labs in 1972.
- General-purpose, structured, middle-level programming language.
- Known as the mother of all modern languages.
- Features: Fast, Portable, Structured, Rich Library, Low-level access.

2. Structure of a C Program
#include <stdio.h>
int main()
{
printf("Hello, World!");
return 0;
}

3. Basic Elements of C
- Keywords → Predefined words (int, float, if, else, return)
- Identifiers → User-defined names
- Constants → Fixed values
- Variables → Named memory locations
- Data Types: int, float, char, double

4. Input & Output


printf("Enter your age: ");
scanf("%d", &age;);
printf("You are %d years old", age);

5. Operators in C
- Arithmetic → +, -, *, /, %
- Relational → ==, !=, <, >, <=, >=
- Logical → &&, ||, !
- Assignment → =, +=, -=
- Increment/Decrement → ++, --

6. Control Statements
if (age >= 18)
printf("Eligible");
else
printf("Not eligible");

switch(choice) {
case 1: printf("One"); break;
case 2: printf("Two"); break;
default: printf("Invalid");
}

7. Loops
for(int i=1; i<=5; i++)
printf("%d ", i);

while(i<=5) { printf("%d ", i); i++; }

do { printf("%d ", i); i++; } while(i<=5);

8. Arrays
int marks[5] = {90, 80, 70, 60, 50};
for(int i=0; i<5; i++)
printf("%d ", marks[i]);

9. Strings
char name[20];
scanf("%s", name);
printf("Hello %s", name);

10. Functions
void greet() { printf("Hello!"); }
int main() { greet(); return 0; }

11. Pointers
int a = 10;
int *p = &a;
printf("%d", *p);

12. Structures
struct Student { int id; char name[20]; };
struct Student s1 = {1, "Raj"};
printf("%d %s", [Link], [Link]);

13. File Handling


FILE *f;
f = fopen("[Link]", "w");
fprintf(f, "Hello File");
fclose(f);

You might also like