SlideShare a Scribd company logo
ONLINE CLASS
24 JAN 2024
COMPUTER PROGRAM
• A computer program is a sequence or set of instructions in a programming language for a computer
to execute. It is one component of software, which also includes documentation and other intangible
components.
C Language Programming Introduction Lecture
C Language Programming Introduction Lecture
C Language Programming Introduction Lecture
WRITE THE BASIC STRUCTURE OF C PROGRAMMING
LANGUAGE.
#include <stdio.h>
int main()
{
// Print Name
printf("Name : Alexandra Abramovn");
// Print Date of Birth
printf("DOB : July 14, 1975n");
// Print Mobile Number
printf("Mobile : 99-9999999999n");
// Indicate successful execution
return(0);
}
EXPLANATION
• #include <stdio.h>: This line includes the standard input-output library, which contains functions
for reading and writing data to and from the console.
• int main(): This is the main function of the program, where execution begins. It returns an integer
value, typically 0, to indicate successful execution.
• Inside the "main()" function, there are three printf statements. The "printf()" function is used to print
formatted text to the console. Each printf statement prints a line of text with specific information:
• printf ("Name : Alexandra Abramovn"); prints "Name : Alexandra Abramov" followed by a newline
character, which moves the cursor to the next line.
• printf ("DOB : July 14, 1975n"); prints "DOB : July 14, 1975" followed by a newline character.
• printf ("Mobile : 99-9999999999n"); prints "Mobile : 99-9999999999" followed by a newline character.
• return(0);: This line indicates the end of the main function and returns 0.
THINGS TO KNOW
• printf is used for displaying output with formatted strings.
• scanf is used for reading input with formatted strings.
• %d in scanf tells the program to expect an integer input
• i.e. %d is a way of telling the program to handle integer data when displaying output (with printf) or
when reading input (with scanf).
C is case sensitive. All commands in C must be lowercase.
EXAMPLE
WRITE A C PROGRAM TO INPUT TWO NUMBERS AND SHOW
ADDITION & SUBTRACTION.
#include <stdio.h>
int main()
{
int n1, n2;
printf("Enter First number: ");
scanf("%d", &n1);
printf("Enter Second number: ");
scanf("%d", &n2);
printf("Sum of Given Two Numbers =: %d n", n1+n2);
printf("Subtraction of Given Two Numbers =: %d n", n1-
n2);
printf("Product of Given Two Numbers =: %d n", n1*n2);
return 0;
}
WRITE A C PROGRAM TO INPUT TWO NUMBERS AND DIVIDE.
#include<stdio.h>
int main(){
int num1, num2, quotient;
//Asking for input
printf("Enter first number: ");
scanf("%d", &num1);
printf("Enter second number: ");
scanf("%d", &num2);
//Computing quotient
quotient = num1 / num2;
printf("Quotient: %d", quotient);
return 0;
}
WRITE A C PROGRAM TO SHOW THE SQUARE OF AN
INPUTTED NUMBER.
#include <stdio.h>
int main()
{
int number;
printf("Enter a number: ");
scanf("%d", &number);
printf("Square of Number is: %dn",
number*number);
return 0;
}
WRITE A C PROGRAM TO ASK A NUMBER INPUT FROM A USER
AND DETERMINE WHETHER THE NUM IS EVEN OR ODD.
#include <stdio.h>
int main()
{
int n;
printf("Enter A number: ");
scanf("%d", &n);
if (n % 2 == 0)
{
printf("%d is an even number.n", n);
}
else
{
printf("%d is an odd number.n", n);
}
return 0;
}
WRITE A C PROGRAM TO SHOW THE TABLE OF AN INPUTTED
NUMBER.
• #include <stdio.h>
• int main() {
• int number;
• // Input number from user
• printf("Enter a number: ");
• scanf("%d", &number);
• // Display multiplication table
• printf("Multiplication table for %d:n", number);
• for (int i = 1; i <= 10; ++i) {
• printf("%d x %d = %dn", number, i, number * i);
• }
• return 0;
• }
H.W
• Write a C program to compute the perimeter and area of a rectangle with a length of 7 inches and
width of 5 inches.
Expected Output:
Perimeter of the rectangle = 24 inches
Area of the rectangle = 35 square inches
• Write a C program to compute the perimeter and area of a circle with user input radius.
Expected Output Example:
Perimeter of the Circle = 37.680000 inches
Area of the Circle = 113.040001 square inches
• Write a C program to convert specified days into years, weeks and days.
Note: Ignore leap year.

More Related Content

Similar to C Language Programming Introduction Lecture (20)

PPTX
Cpu
Mohit Jain
 
PPT
Fundamental of C Programming Language and Basic Input/Output Function
imtiazalijoono
 
PPTX
Introduction to c programming
SaranyaK68
 
PPTX
Introduction to c programming
SaranyaK68
 
PPTX
CHAPTER 4
mohd_mizan
 
PPTX
A brief introduction to C Language
Mohamed Elsayed
 
PPT
424769021-1-First-C-Program-1-ppt (1).ppt
advRajatSharma
 
PDF
Cse115 lecture04introtoc programming
Md. Ashikur Rahman
 
PDF
CP Handout#2
trupti1976
 
DOCX
Hargun
Mukund Trivedi
 
PDF
UNIT1 PPS of C language for first year first semester
Aariz2
 
PPTX
CSE 1102 - Lecture 1 - C Fundamentals.pptx
Salim Shadman Ankur
 
PPTX
C LANGUAGE.pptx
digitalworld70
 
PPTX
C LANGUAGE.pptx
Learnwithjagrati
 
PPTX
C for Engineers
Julie Iskander
 
DOCX
Best C Programming Solution
yogini sharma
 
PPTX
c_pro_introduction.pptx
RohitRaj744272
 
PPTX
C programming(part 3)
Dr. SURBHI SAROHA
 
PPT
270_1_CIntro_Up_To_Functions.ppt
JoshCasas1
 
Fundamental of C Programming Language and Basic Input/Output Function
imtiazalijoono
 
Introduction to c programming
SaranyaK68
 
Introduction to c programming
SaranyaK68
 
CHAPTER 4
mohd_mizan
 
A brief introduction to C Language
Mohamed Elsayed
 
424769021-1-First-C-Program-1-ppt (1).ppt
advRajatSharma
 
Cse115 lecture04introtoc programming
Md. Ashikur Rahman
 
CP Handout#2
trupti1976
 
UNIT1 PPS of C language for first year first semester
Aariz2
 
CSE 1102 - Lecture 1 - C Fundamentals.pptx
Salim Shadman Ankur
 
C LANGUAGE.pptx
digitalworld70
 
C LANGUAGE.pptx
Learnwithjagrati
 
C for Engineers
Julie Iskander
 
Best C Programming Solution
yogini sharma
 
c_pro_introduction.pptx
RohitRaj744272
 
C programming(part 3)
Dr. SURBHI SAROHA
 
270_1_CIntro_Up_To_Functions.ppt
JoshCasas1
 

Recently uploaded (20)

PDF
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
PPTX
How to use _name_search() method in Odoo 18
Celine George
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PPTX
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
PPTX
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
PPTX
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
PPTX
A Case of Identity A Sociological Approach Fix.pptx
Ismail868386
 
PDF
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
PPTX
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
PDF
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
PDF
COM and NET Component Services 1st Edition Juval Löwy
kboqcyuw976
 
PPTX
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
DOCX
DLL english grade five goof for one week
FlordelynGonzales1
 
DOCX
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
PDF
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
PPTX
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
PPTX
Elo the HeroTHIS IS A STORY ABOUT A BOY WHO SAVED A LITTLE GOAT .pptx
JoyIPanos
 
PDF
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
PPTX
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
How to use _name_search() method in Odoo 18
Celine George
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
A Case of Identity A Sociological Approach Fix.pptx
Ismail868386
 
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
COM and NET Component Services 1st Edition Juval Löwy
kboqcyuw976
 
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
DLL english grade five goof for one week
FlordelynGonzales1
 
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
Elo the HeroTHIS IS A STORY ABOUT A BOY WHO SAVED A LITTLE GOAT .pptx
JoyIPanos
 
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
Ad

C Language Programming Introduction Lecture

  • 2. COMPUTER PROGRAM • A computer program is a sequence or set of instructions in a programming language for a computer to execute. It is one component of software, which also includes documentation and other intangible components.
  • 6. WRITE THE BASIC STRUCTURE OF C PROGRAMMING LANGUAGE. #include <stdio.h> int main() { // Print Name printf("Name : Alexandra Abramovn"); // Print Date of Birth printf("DOB : July 14, 1975n"); // Print Mobile Number printf("Mobile : 99-9999999999n"); // Indicate successful execution return(0); }
  • 7. EXPLANATION • #include <stdio.h>: This line includes the standard input-output library, which contains functions for reading and writing data to and from the console. • int main(): This is the main function of the program, where execution begins. It returns an integer value, typically 0, to indicate successful execution. • Inside the "main()" function, there are three printf statements. The "printf()" function is used to print formatted text to the console. Each printf statement prints a line of text with specific information: • printf ("Name : Alexandra Abramovn"); prints "Name : Alexandra Abramov" followed by a newline character, which moves the cursor to the next line. • printf ("DOB : July 14, 1975n"); prints "DOB : July 14, 1975" followed by a newline character. • printf ("Mobile : 99-9999999999n"); prints "Mobile : 99-9999999999" followed by a newline character. • return(0);: This line indicates the end of the main function and returns 0.
  • 8. THINGS TO KNOW • printf is used for displaying output with formatted strings. • scanf is used for reading input with formatted strings. • %d in scanf tells the program to expect an integer input • i.e. %d is a way of telling the program to handle integer data when displaying output (with printf) or when reading input (with scanf). C is case sensitive. All commands in C must be lowercase.
  • 10. WRITE A C PROGRAM TO INPUT TWO NUMBERS AND SHOW ADDITION & SUBTRACTION. #include <stdio.h> int main() { int n1, n2; printf("Enter First number: "); scanf("%d", &n1); printf("Enter Second number: "); scanf("%d", &n2); printf("Sum of Given Two Numbers =: %d n", n1+n2); printf("Subtraction of Given Two Numbers =: %d n", n1- n2); printf("Product of Given Two Numbers =: %d n", n1*n2); return 0; }
  • 11. WRITE A C PROGRAM TO INPUT TWO NUMBERS AND DIVIDE. #include<stdio.h> int main(){ int num1, num2, quotient; //Asking for input printf("Enter first number: "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", &num2); //Computing quotient quotient = num1 / num2; printf("Quotient: %d", quotient); return 0; }
  • 12. WRITE A C PROGRAM TO SHOW THE SQUARE OF AN INPUTTED NUMBER. #include <stdio.h> int main() { int number; printf("Enter a number: "); scanf("%d", &number); printf("Square of Number is: %dn", number*number); return 0; }
  • 13. WRITE A C PROGRAM TO ASK A NUMBER INPUT FROM A USER AND DETERMINE WHETHER THE NUM IS EVEN OR ODD. #include <stdio.h> int main() { int n; printf("Enter A number: "); scanf("%d", &n); if (n % 2 == 0) { printf("%d is an even number.n", n); } else { printf("%d is an odd number.n", n); } return 0; }
  • 14. WRITE A C PROGRAM TO SHOW THE TABLE OF AN INPUTTED NUMBER. • #include <stdio.h> • int main() { • int number; • // Input number from user • printf("Enter a number: "); • scanf("%d", &number); • // Display multiplication table • printf("Multiplication table for %d:n", number); • for (int i = 1; i <= 10; ++i) { • printf("%d x %d = %dn", number, i, number * i); • } • return 0; • }
  • 15. H.W • Write a C program to compute the perimeter and area of a rectangle with a length of 7 inches and width of 5 inches. Expected Output: Perimeter of the rectangle = 24 inches Area of the rectangle = 35 square inches • Write a C program to compute the perimeter and area of a circle with user input radius. Expected Output Example: Perimeter of the Circle = 37.680000 inches Area of the Circle = 113.040001 square inches • Write a C program to convert specified days into years, weeks and days. Note: Ignore leap year.