SlideShare a Scribd company logo
1
University of Sargodha
Mandi Bahauddin campus
LAB Sheet #1
C Lab Report Submitted By:
Name: M Umar
Roll No: BSSE-F17-18
Submitted To:
Department of CS & IT University of Sargodha M.B.Din
Lab Date:2 January 2018 Marks & Signature
Submission Date: 16th
January 2018
2
Lab #1
Program No. 1
Title:
Write a program to display “hello world” in C.
Problem Analysis:
It is required to get output of a Hello World using printf() function.
Input variables Processing
variables
Output variables Header files
printf () stdio.h
Algorithm:
1. Start
2. Print Hello World
3. Stop
Code:
#include<stdio.h>
Int main(void)
{
Printf(“Hello World!n”);
return 0;
}
Output:
Hello World!
Program No. 2
Title:
Write a program to add two numbers (5&7) and display its sum.
Problem Analysis:
Based on the problem it is required to print the sum of two numbers which are given.
First declare three integers and assign them value and then calculate the sum and
display on the screen.
3
Input variables Processing
variables
Output variables Header files
int a,b,sum printf() -------- stdio.h
Algorithm:
1. Start
2. Define variable (a,b,sum)
3. Assign value to variables (a,b)
4. Calculate sum as sum=a+b
5. Display the sum
6. Stop
Code:
#include<stdio.h>
int main (void)
{
int a,b;
int sum;
a=5;
b=7;
sum = a + b;
printf("Sum = %d", sum);
return 0;
}
Output:
Sum = 12
Program No. 3
Title:
Write a program to multiply two numbers (10&8) and display its product.
Problem Analysis:
4
According to the problem we need to multiply two numbers which we assign to declared
variables and display their result using printf() function
Input variables Processing
variables
Output variables Header files
int a,b,multiply printf() stdio.h
Algorithm:
1. Start
2. Define variables (a,b,multiply)
3. Assign value to (a,b)
4. Multiply both variables
5. Display the result
6. Stop
Code:
#include<stdio.h>
int main(void)
{
int a,b;
int multiply;
a=10;
b=8;
multiply = a*b;
printf("The product is %d", multiply);
return 0;
}
Output:
The product is 80
Program No. 4
Title:
Write a program to calculate area of a circle having its radius (r=5).
Problem Analysis:
5
According to the problem it is required to define two float variables and then assign
them value. Use a formula to calculate the area of a circle and print the value on the
screen.
Input variables Processing
variables
Output variables Header files
float radius
float area
printf() ------- stdio.h
Algorithm:
1. Start
2. Define variables (radius, area)
3. Assign value to variables
4. Calculate values
5. Display the result
6. Stop
Code:
#include<stdio.h>
int main()
{
float radius;
float area;
radius = 5;
area = 3.14*radius*radius;
printf("The area is = %.2f", area);
return 0;
}
Output:
The area is = 78.50
Program No. 5
Title:
6
Write a program to calculate area of an ellipse having its axes (minor=4cm,
major=6cm).
Problem Analysis:
According to the problem it is required to calculate the area of an ellipse having axis
minor=4cm and major=6cm.First define four variables assign the values given 4cm and
6cm to minor and major. Apply the formula of ellipse and display the result.
Input variables Processing
variables
Output variables Header files
int minor;
int major;
float pi;
float ellipse;
printf() ------- stdio.h
Algorithm:
1. Start
2. Define variables (minor ,major, pi)
3. Assign values to variables
4. Applied formula of ellipse
5. Display the result
6. Stop
Code:
#include<stdio.h>
int main(){
int minor;
int major;
float pi;
float ellipse;
minor = 4;
major = 6;
pi = 3.14;
ellipse = pi * minor * major;
printf("area of ellipse is = %.2f", ellipse);
return 0;
}
Output:
7
Area of ellipse is = 75.36
Program No. 6
Title:
Write a program to calculate simple interest for a given P=4000, T=2, R=5.5. (I =
P*T*R/100).
Problem Analysis:
According to the problem it is required to calculate simple interest for P,T,R and divide
them with 100 which is declared to i, assign the values to P,R and T and calculate them
and display the result.
Input variables Processing
variables
Output variables Header files
int p;
int t;
float r;
int div;
int i;
printf() ------- stdio.h
Algorithm:
1. Start
2. Define variables (p, t, r, i)
3. Assign values to variables
4. Calculate values
5. Display the result
6. Stop
Code:
#include<stdio.h>
int main ()
{
int p=4000;
int t=2;
float r=5.5;
int div=100;
int i;
i = p*t*r/100;
printf("The result is = %d", i);
return 0;}
8
Output: The result is = 440

More Related Content

What's hot

C program report tips
C program report tipsC program report tips
C program report tipsHarry Pott
 
C programming
C programmingC programming
Strings in C
Strings in CStrings in C
Strings in C
Kamal Acharya
 
C Language
C LanguageC Language
C Language
Aakash Singh
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by Robin
Shariful Haque Robin
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
Shaina Arora
 
Structure in C
Structure in CStructure in C
Structure in C
Kamal Acharya
 
Call by value
Call by valueCall by value
Call by valueDharani G
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
Rabin BK
 
c-programming
c-programmingc-programming
c-programming
Zulhazmi Harith
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
sneha2494
 
Mathematics Function in C ,ppt
Mathematics Function in C ,pptMathematics Function in C ,ppt
Mathematics Function in C ,ppt
AllNewTeach
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
Sokngim Sa
 
Functions in C
Functions in CFunctions in C
Functions in C
Kamal Acharya
 
String C Programming
String C ProgrammingString C Programming
String C Programming
Prionto Abdullah
 
C if else
C if elseC if else
C if else
Ritwik Das
 

What's hot (20)

C lab-programs
C lab-programsC lab-programs
C lab-programs
 
C program report tips
C program report tipsC program report tips
C program report tips
 
C programming
C programmingC programming
C programming
 
Strings in C
Strings in CStrings in C
Strings in C
 
C Language
C LanguageC Language
C Language
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by Robin
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Structure in C
Structure in CStructure in C
Structure in C
 
Call by value
Call by valueCall by value
Call by value
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
c-programming
c-programmingc-programming
c-programming
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
Mathematics Function in C ,ppt
Mathematics Function in C ,pptMathematics Function in C ,ppt
Mathematics Function in C ,ppt
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
Strings
StringsStrings
Strings
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Functions in C
Functions in CFunctions in C
Functions in C
 
String C Programming
String C ProgrammingString C Programming
String C Programming
 
Function in c
Function in cFunction in c
Function in c
 
C if else
C if elseC if else
C if else
 

Similar to C programming Lab 1

Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
CharuJain396881
 
Programming in c
Programming in cProgramming in c
Programming in c
Ashutosh Srivasatava
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
gamingwithfaulty
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
Zaibi Gondal
 
C-LOOP-Session-2.pptx
C-LOOP-Session-2.pptxC-LOOP-Session-2.pptx
C-LOOP-Session-2.pptx
Sarkunavathi Aribal
 
Python Manuel-R2021.pdf
Python Manuel-R2021.pdfPython Manuel-R2021.pdf
Python Manuel-R2021.pdf
RamprakashSingaravel1
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
Abir Hossain
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
Md Masudur Rahman
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 studrohassanie
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
Don Dooley
 
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming  EECS 1.docxProject 2Project 2.pdfIntroduction to Programming  EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
wkyra78
 
First c program
First c programFirst c program
First c program
Komal Pardeshi
 
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branchComputer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
SAKSHIGAWADE2
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans incnayakq
 
PF LAB ASSIGNMENT
PF LAB ASSIGNMENTPF LAB ASSIGNMENT
PF LAB ASSIGNMENT
minqadtahir
 
Lab 2
Lab 2Lab 2

Similar to C programming Lab 1 (20)

Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
C-LOOP-Session-2.pptx
C-LOOP-Session-2.pptxC-LOOP-Session-2.pptx
C-LOOP-Session-2.pptx
 
Python Manuel-R2021.pdf
Python Manuel-R2021.pdfPython Manuel-R2021.pdf
Python Manuel-R2021.pdf
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 stud
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming  EECS 1.docxProject 2Project 2.pdfIntroduction to Programming  EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
 
Labsheet1stud
Labsheet1studLabsheet1stud
Labsheet1stud
 
First c program
First c programFirst c program
First c program
 
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branchComputer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
 
Lab 1
Lab 1Lab 1
Lab 1
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
PF LAB ASSIGNMENT
PF LAB ASSIGNMENTPF LAB ASSIGNMENT
PF LAB ASSIGNMENT
 
Lab 2
Lab 2Lab 2
Lab 2
 

More from Zaibi Gondal

Modal Verbs
Modal VerbsModal Verbs
Modal Verbs
Zaibi Gondal
 
Parts of speech1
Parts of speech1Parts of speech1
Parts of speech1
Zaibi Gondal
 
Wirless Security By Zohaib Zeeshan
Wirless Security By Zohaib ZeeshanWirless Security By Zohaib Zeeshan
Wirless Security By Zohaib Zeeshan
Zaibi Gondal
 
C project on a bookshop for saving of coustmer record
C project on a bookshop for saving of coustmer recordC project on a bookshop for saving of coustmer record
C project on a bookshop for saving of coustmer record
Zaibi Gondal
 
Backup data
Backup data Backup data
Backup data
Zaibi Gondal
 
Functional english
Functional englishFunctional english
Functional english
Zaibi Gondal
 
application of electronics in computer
application of electronics in computerapplication of electronics in computer
application of electronics in computer
Zaibi Gondal
 
Model Verbs
Model VerbsModel Verbs
Model Verbs
Zaibi Gondal
 

More from Zaibi Gondal (8)

Modal Verbs
Modal VerbsModal Verbs
Modal Verbs
 
Parts of speech1
Parts of speech1Parts of speech1
Parts of speech1
 
Wirless Security By Zohaib Zeeshan
Wirless Security By Zohaib ZeeshanWirless Security By Zohaib Zeeshan
Wirless Security By Zohaib Zeeshan
 
C project on a bookshop for saving of coustmer record
C project on a bookshop for saving of coustmer recordC project on a bookshop for saving of coustmer record
C project on a bookshop for saving of coustmer record
 
Backup data
Backup data Backup data
Backup data
 
Functional english
Functional englishFunctional english
Functional english
 
application of electronics in computer
application of electronics in computerapplication of electronics in computer
application of electronics in computer
 
Model Verbs
Model VerbsModel Verbs
Model Verbs
 

Recently uploaded

Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 

Recently uploaded (20)

Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 

C programming Lab 1

  • 1. 1 University of Sargodha Mandi Bahauddin campus LAB Sheet #1 C Lab Report Submitted By: Name: M Umar Roll No: BSSE-F17-18 Submitted To: Department of CS & IT University of Sargodha M.B.Din Lab Date:2 January 2018 Marks & Signature Submission Date: 16th January 2018
  • 2. 2 Lab #1 Program No. 1 Title: Write a program to display “hello world” in C. Problem Analysis: It is required to get output of a Hello World using printf() function. Input variables Processing variables Output variables Header files printf () stdio.h Algorithm: 1. Start 2. Print Hello World 3. Stop Code: #include<stdio.h> Int main(void) { Printf(“Hello World!n”); return 0; } Output: Hello World! Program No. 2 Title: Write a program to add two numbers (5&7) and display its sum. Problem Analysis: Based on the problem it is required to print the sum of two numbers which are given. First declare three integers and assign them value and then calculate the sum and display on the screen.
  • 3. 3 Input variables Processing variables Output variables Header files int a,b,sum printf() -------- stdio.h Algorithm: 1. Start 2. Define variable (a,b,sum) 3. Assign value to variables (a,b) 4. Calculate sum as sum=a+b 5. Display the sum 6. Stop Code: #include<stdio.h> int main (void) { int a,b; int sum; a=5; b=7; sum = a + b; printf("Sum = %d", sum); return 0; } Output: Sum = 12 Program No. 3 Title: Write a program to multiply two numbers (10&8) and display its product. Problem Analysis:
  • 4. 4 According to the problem we need to multiply two numbers which we assign to declared variables and display their result using printf() function Input variables Processing variables Output variables Header files int a,b,multiply printf() stdio.h Algorithm: 1. Start 2. Define variables (a,b,multiply) 3. Assign value to (a,b) 4. Multiply both variables 5. Display the result 6. Stop Code: #include<stdio.h> int main(void) { int a,b; int multiply; a=10; b=8; multiply = a*b; printf("The product is %d", multiply); return 0; } Output: The product is 80 Program No. 4 Title: Write a program to calculate area of a circle having its radius (r=5). Problem Analysis:
  • 5. 5 According to the problem it is required to define two float variables and then assign them value. Use a formula to calculate the area of a circle and print the value on the screen. Input variables Processing variables Output variables Header files float radius float area printf() ------- stdio.h Algorithm: 1. Start 2. Define variables (radius, area) 3. Assign value to variables 4. Calculate values 5. Display the result 6. Stop Code: #include<stdio.h> int main() { float radius; float area; radius = 5; area = 3.14*radius*radius; printf("The area is = %.2f", area); return 0; } Output: The area is = 78.50 Program No. 5 Title:
  • 6. 6 Write a program to calculate area of an ellipse having its axes (minor=4cm, major=6cm). Problem Analysis: According to the problem it is required to calculate the area of an ellipse having axis minor=4cm and major=6cm.First define four variables assign the values given 4cm and 6cm to minor and major. Apply the formula of ellipse and display the result. Input variables Processing variables Output variables Header files int minor; int major; float pi; float ellipse; printf() ------- stdio.h Algorithm: 1. Start 2. Define variables (minor ,major, pi) 3. Assign values to variables 4. Applied formula of ellipse 5. Display the result 6. Stop Code: #include<stdio.h> int main(){ int minor; int major; float pi; float ellipse; minor = 4; major = 6; pi = 3.14; ellipse = pi * minor * major; printf("area of ellipse is = %.2f", ellipse); return 0; } Output:
  • 7. 7 Area of ellipse is = 75.36 Program No. 6 Title: Write a program to calculate simple interest for a given P=4000, T=2, R=5.5. (I = P*T*R/100). Problem Analysis: According to the problem it is required to calculate simple interest for P,T,R and divide them with 100 which is declared to i, assign the values to P,R and T and calculate them and display the result. Input variables Processing variables Output variables Header files int p; int t; float r; int div; int i; printf() ------- stdio.h Algorithm: 1. Start 2. Define variables (p, t, r, i) 3. Assign values to variables 4. Calculate values 5. Display the result 6. Stop Code: #include<stdio.h> int main () { int p=4000; int t=2; float r=5.5; int div=100; int i; i = p*t*r/100; printf("The result is = %d", i); return 0;}