Introduction To Programming Language C/C++
Introduction To Programming Language C/C++
Module: COMPUTER
PROGRAMMING IN C++
Code: CSM108
2 INTRODUCTION TO C 04/12/2024
Introduction to C Language
3 INTRODUCTION TO C 04/12/2024
Introduction to Programming Languages
Introduction:
4 INTRODUCTION TO C 04/12/2024
Syntax: The specific rules and structure
used to write code in a programming
language.
5 INTRODUCTION TO C 04/12/2024
Control Structures: Statements used to
control the flow of a program, such as if-else
statements, loops, and function calls.
6 INTRODUCTION TO C 04/12/2024
A programming language is a formal language that
specifies a set of instructions for a computer to
perform specific tasks.
8 INTRODUCTION TO C 04/12/2024
A programming language should be well
structured and documented so that it is
suitable for application development.
9 INTRODUCTION TO C 04/12/2024
Basic Terminologies in Programming
Languages:
11 INTRODUCTION TO C 04/12/2024
Tips for learning new programming language:
2. Code daily: Like any skill, the only way to get good at
programming is by practicing regularly. Try to write code
every day, even if it’s just a few lines.
13 INTRODUCTION TO C 04/12/2024
6. Learn from others: Find a mentor or
someone who is experienced in the language
you’re trying to learn. Ask them questions,
review their code, and try to understand how
they solve problems.
14 INTRODUCTION TO C 04/12/2024
EVOLUTION OF PROGRAMMING LANGUAGES
There are five generations of Programming
languages. They are:
1) First-Generation Languages :
These are low-level languages like machine
language.
2) Second-Generation Languages :
3) Third-Generation Languages :
These are high-level languages like C, C++,
Java,
15 VisualTO Basic,
INTRODUCTION C and JavaScript. 04/12/2024
EVOLUTION OF PROGRAMMING LANGUAGES
17 INTRODUCTION TO C 04/12/2024
EVOLUTION OF PROGRAMMING LANGUAGES
The first two generations are called
low-level languages.
The next three generations are called
high-level languages.
18 INTRODUCTION TO C 04/12/2024
EVOLUTION OF PROGRAMMING LANGUAGES
1. First-Generation Language :
19 INTRODUCTION TO C 04/12/2024
EVOLUTION OF PROGRAMMING LANGUAGES
Advantages :
Disadvantages :
20 INTRODUCTION TO C 04/12/2024
EVOLUTION OF PROGRAMMING LANGUAGES
2. Second Generation Language :
1. It is easier to understand if
compared to machine language.
2. Modifications are easy.
3. Correction & location of errors are
easy.
Disadvantages :
1. Assembler is required.
22 INTRODUCTION TO C 04/12/2024
EVOLUTION OF PROGRAMMING LANGUAGES
3. Third-Generation Language :
24 INTRODUCTION TO C 04/12/2024
EVOLUTION OF PROGRAMMING LANGUAGES
Advantages :
Disadvantages :
1. Compiler/ interpreter is needed.
2. Different compilers are needed for
different machines.
INTRODUCTION TO C
25 04/12/2024
EVOLUTION OF PROGRAMMING LANGUAGES
26 INTRODUCTION TO C 04/12/2024
EVOLUTION OF PROGRAMMING LANGUAGES
Advantages :
Disadvantages :
Advantages :
Disadvantages :
30 INTRODUCTION TO C 04/12/2024
ALGOL 60 turned out to be too abstract
31 INTRODUCTION TO C 04/12/2024
Martin Richards developed basic combined
Programming Language at Cambridge
(BCPL) University to overcome the
problem of CPL, but it turned to be less
powerful and too specific.
32 INTRODUCTION TO C 04/12/2024
Dennis Ritchie inherited the features
of B and BCPL, added some of his own
featured and developed the C Language.
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}37 Introduction in C Language 04/12/2024
Example explained
int main()
{
printf("Hello World!");
return 0;
}
Example:
printf("Hello World!");
printf("Have a good day!");
return 0;
1. printf("Hello World!");
2. printf("Have a good day!");
3. return 0;
Example:
#include <stdio.h>
int main()
{
printf("Hello World!");
printf("I am learning C.");
printf("And it is awesome!");
return 0;
}
49 Introduction in C Language 04/12/2024
New Lines
Example:
#include <stdio.h>
int main()
{
printf("Hello World!\n");
printf("I am learning C.");
return 0;
}
Example:
#include <stdio.h>
int main()
{
printf("Hello World!\n I am learning C.\n And it is
awesome!");
return 0;
}
int main()
{
printf("Hello World!\n\n");
printf("I am learning C.");
return 0;
}
Single-line Comments
Example:
type variableName;
Example:
Create a variable called myNum of type int and
assign the value 15 to it:
Example:
// Declare a variable
int myNum;
myNum = 15;
Example:
// Create variables
// Print variables
printf("%d\n", myNum);
printf("%f\n", myFloatNum);
printf("%c\n", myLetter);
#include <stdio.h>
int main() {
// Create variables
int myNum = 15; // Integer (whole number)
float myFloatNum = 5.99; // Floating point number
char myLetter = 'D'; // Character
// Print variables
printf("%d\n", myNum);
printf("%f\n", myFloatNum);
printf("%c\n", myLetter);
return 0;
}
Example:
int main() {
int myNum = 15;
printf("My favorite number is: %d", myNum);
return 0;
}
Example:
int main() {
int myNum = 15;
char myLetter = 'D';
printf("My number is %d and my letter is %c",
myNum, myLetter);
return 0;
}
67 INTRODUCTION TO C 04/12/2024
1. Write a Program to Print “Hello World!” on the
Console.
2. Write a c program that read age, sex, height of a
given student from the keyboard and display the
output on the screen.
3. Write a Program to find the Sum of two numbers
entered by the user.
4. Write a Program to Swap the values of two
variables
5. Write a program to calculate the area of a
rectangle
68 INTRODUCTION TO C 04/12/2024
6. Write a c program that calculate the area of a
circle using constants.
7. Write a program to convert from Celsius degree
(0C) to Fahrenheit degrees (0F)
Formular to use: fahrenheit = (1.8 * celsius) + 32;
69 INTRODUCTION TO C 04/12/2024
End
70 INTRODUCTION TO C 04/12/2024