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

Chapter 1 Code 2546

The document is a tutorial on the C programming language, covering topics from basic to advanced levels. It includes chapters on variables, data types, input/output, functions, pointers, arrays, and more. The first chapter provides examples of basic programs, variable declarations, comments, and input/output operations.

Uploaded by

vipjain71
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)
4 views3 pages

Chapter 1 Code 2546

The document is a tutorial on the C programming language, covering topics from basic to advanced levels. It includes chapters on variables, data types, input/output, functions, pointers, arrays, and more. The first chapter provides examples of basic programs, variable declarations, comments, and input/output operations.

Uploaded by

vipjain71
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 Tutorial

(Basic to Advanced)

Topics to be covered :
Installation + Setup
Chapter 1 - Variables, Data types + Input/Output
Chapter 2 - Instructions & Operators
Chapter 3 - Conditional Statements
Chapter 4 - Loop Control Statements
Chapter 5 - Functions & Recursion
Chapter 6 - Pointers
Chapter 7 - Arrays
Chapter 8 - Strings
Chapter 9 - Structures
Chapter 10 - File I/O
Chapter 11 - Dynamic Memory Allocation

Variables, Data Types + Input/Output


(Chapter 1)

V
1. First Program
#include<stdio.h>

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

2. Variables & Data Types + Constants & Keywords


#include<stdio.h>

int main() {
int number;
int age;
int price;
return 0;
}
#include<stdio.h>

int main() {
int age = 22;
float pi = 3.14;
char percentage = '%';
return 0;
}

3. Comments
#include<stdio.h>
//This program prints Hello World
int main() {
printf("Hello World");
return 0;
}

4. Output
#include<stdio.h>

int main() {
int age = 22;
float pi = 3.14;
char percentage = '%';

printf("age is %d", age);


printf("age is %f", pi);
printf("age is %c", percentage);
return 0;
}

5. Input (Sum of 2 numbers)


#include<stdio.h>

int main() {
int a, b;

printf("enter a \n");
scanf("%d", &a);

printf("enter b \n");
scanf("%d", &b);

printf("sum of a & b is : %d \n", a+b);

return 0;
}

6. Practice Qs 1 (Area of Square)


#include<stdio.h>
//area of square
int main() {
int side;
scanf("%d", &side);
printf("%d", side * side);
return 0;
}

7. Practice Qs 2 (Area of Circle)


#include<stdio.h>
//area of square
int main() {
float radius;
scanf("%f", &radius);
printf("%f", 3.14 * radius * radius);
return 0;
}

You might also like