C & C++ Programming
Computer ScienceChapter 1 — Introduction to C and C++
Lesson 1.5 : Basic Structure of C and C++ Programs
Reading & Interactive Lesson
Basic Structure of C and C++ Programs
Reading Material & Notes
Basic Structure of C and C++ Programs
Understanding the structure of a program is important before writing larger C and C++ applications.
Basic Structure of a C Program
#include <stdio.h>
int main()
{
int number = 10;
printf("Number = %d", number);
return 0;
}
Parts of the C Program
- Header File: Provides declarations for library functions.
- main() Function: Program execution starts from the main function.
- Variable Declaration: Variables are declared before they are used.
- Statements: Instructions executed by the program.
- return Statement: Returns a value from the main function.
Basic Structure of a C++ Program
#include <iostream>
using namespace std;
int main()
{
int number = 10;
cout << "Number = " << number;
return 0;
}
Important Programming Concepts
- Keywords
- Identifiers
- Variables
- Constants
- Data types
- Operators
- Expressions
- Statements
- Functions
Key Points
- Every C/C++ program has an entry point.
- The main() function is normally the starting point of execution.
- Header files provide library functionality.
- C++ supports all major procedural programming concepts of C along with object-oriented features.
Course Curriculum
10 Chapters • 50 Lessons
Chapter 1 — Introduction to C and C++
5 Lessons
Chapter 2 — Variables, Data Types and Operators
5 Lessons
Chapter 3 — Conditional Statements and Loops
5 Lessons
Chapter 4 — Functions and Modular Programming
5 Lessons
Chapter 5 — Arrays and Strings
5 Lessons
Chapter 6 — Pointers and References
5 Lessons
Chapter 7 — Structures, Unions and Enumerations
5 Lessons
Chapter 8 — Object-Oriented Programming in C++
5 Lessons
Chapter 9 — Inheritance, Polymorphism and Templates
5 Lessons
Chapter 10 — File Handling and Mini Projects
5 Lessons