SlideShare a Scribd company logo
1 of 8
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

Decoders
DecodersDecoders
Decoders
Re Man
 
C programs
C programsC programs
C programs
Minu S
 

What's hot (20)

Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in c
 
Decoders
DecodersDecoders
Decoders
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Bus system
Bus systemBus system
Bus system
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
Loops in C
Loops in CLoops in C
Loops in C
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Report on c
Report on cReport on c
Report on c
 
8086 micro processor
8086 micro processor8086 micro processor
8086 micro processor
 
c++ lab manual
c++ lab manualc++ lab manual
c++ lab manual
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
 
C programs
C programsC programs
C programs
 
programming in C++ report
programming in C++ reportprogramming in C++ report
programming in C++ report
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
c-programming
c-programmingc-programming
c-programming
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in C
 
Introduction to ibm pc assembly language
Introduction to ibm pc assembly languageIntroduction to ibm pc assembly language
Introduction to ibm pc assembly language
 
C tokens
C tokensC tokens
C tokens
 
Functions in c
Functions in cFunctions in c
Functions in c
 

Similar to C programming Lab 1

Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
Md Masudur Rahman
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 stud
rohassanie
 
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
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
nayakq
 

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
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
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
 

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

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 

Recently uploaded (20)

Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field 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;}