SlideShare a Scribd company logo
Lab Report
Course ID: TE-3702
Course Title:-Computer Application and Programming
(Sessional)
Experiment No. 05
Name:-Introduction to C conditional operator, nested loop
and go to statement.
Submitted by
Name :
ID :
Year and Semester :
Session :
Department :
Mahbubay Rabbani
175035
3/1
2018-19
Textile Engineering
Submitted to
Khawja Imran Masud
Lecturer
Department of CSE
Dhaka University of Engineering & Technology (DUET), Gazipur
Introduction:-
The conditional statements are the decision-making statements which
depends upon the output of the expression.
A loop inside another loop is called a nested loop.
The goto statement is a jump statement which is sometimes also called
unconditional jump statement. The goto statement can be used to jump
from anywhere to anywhere within a function.
Objectives:-
 To know about conditional operator.
 To know about nested loop.
 To know about “goto” statement.
Conditional Operator
Conditional statements are decision-making statements that depend on
the output of the expression.
It is represented by two symbols that are '?' and ':'.
It works on three operands and that’s why it is also called the ternary
operator.
The behavior of the conditional operator is similar to the 'if-else'
statement as 'if-else' statement is also a decision-making statement. This
helps the ternary operator to think of it as a shorthand way to write a
statement.
The ternary operator works with the 3 following principles:-
 The first is a comparison argument
 The second is upon the results of true comparisons
 The third results in a false comparison
Example:-
C program to check student result using conditional operator
Input:-
#include <stdio.h>
int main()
{
int mark;
printf("Enter the mark=");
scanf("%d", &mark);
puts(mark>=40?"Pass":"Fail");
return 0;
}
Output
Nested loop
A loop inside another loop is called a nested loop.
The depth of nested loop depends on the complexity of a problem.
Using a for loop within another for loop is called nested for loop.
In nested for loop one or more statements can be included in the body of
the loop.
Example:-
Input:-
#include <stdio.h>
int main()
{
int a, b;
for(a=1;a<=5;a++)
{
for(b=1;b<=5;b++)
{
printf("%d ",b);
}
printf("n");
}
return 0;
}
Output:-
go to statement
The goto statement is a jump statement which is sometimes called
unconditional jump statement. The goto statement can be used to jump
from anywhere to anywhere within a function. Here a label is used
which is a user-defined identifier and indicates the target statement. It
can be set anywhere in the C program above or below to goto statement.
Example
Write a C program that take the any double numbers between 1 to
10 and calculate the square root of that number.
input:-
#include<stdio.h>
int main()
{
double x,y;
read:
printf("Enter the double number between 1 to 10=");
scanf("%lf", &x);
if(x<0 || x>10)
goto read ;
y=sqrt(x);
printf( "%lf",y);
return 0;
}
Output:-
Home task problems:-
Problem:-
Find the largest number among 3 input numbers using conditional
operator.
Input:-
# include <stdio.h>
int main()
{
int a, b, c, large ;
printf("Enter 1st number=");
scanf("%d",&a);
printf("Enter 2nd number=");
scanf("%d",&b);
printf("Enter 3rd number=");
scanf("%d",&c);
large = a > b ? (a > c ? a : c) : (b > c ? b : c) ;
printf("The largest number is=%d",large);
}
Output:-
Problem:-
Write a C program that display half Pyramid of *
*
* *
* * *
* * * *
* * * * *
Input:-
#include <stdio.h>
int main() {
int i, j, rows;
printf("Enter the number of rows: ");
scanf("%d", &rows);
for (i = 1; i <= rows; i++)
{
for (j = 1; j <= i; j++)
{
printf("* ");
}
printf("n");
}
return 0;
}
Output:-
Problem:-
Write a C program that display Half Pyramid of Numbers
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Input:-
#include <stdio.h>
int main()
{
int i,j,rows;
printf("Enter the number of rows=");
scanf("%d", &rows);
for(i=1; i<=rows; i++)
{for (j=1; j<=i; j++)
{
printf("%d",j);
}
printf("n");
}
return 0;}
Output:-
Problem:-
Write a C program that display Inverted Half Pyramid of *
* * * * *
* * * *
* * *
* *
*
Input:-
#include <stdio.h>
int main()
{
int i,j,rows;
printf("Enter the number of rows=");
scanf("%d", &rows);
for(i=rows; i>=1; i--)
{for (j=1; j<=i; j++)
{
printf("*");
}
printf("n");
}
return 0;
}
Output:-
Lab Assessment:-
Problem:-
Write a C program that displays Inverted Half Pyramid of Number.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Input: 5
Input:-
#include <stdio.h>
int main()
{
int i,j,rows;
printf("Enter the number of rows=");
scanf("%d", &rows);
for(i=rows; i>=1; i--)
{for (j=1; j<=i; j++)
{
printf("%d",j);
}
printf("n");
}
return 0;
}
Output:-
Problem:-
Write a C program that display the pattern given below.
1
2 3
4 5 6
7 8 9 10
Input: 4
Input:-
#include <stdio.h>
int main()
{
int rows, i, j, number = 1;
printf("Enter the number of rows= ");
scanf("%d", &rows);
for (i=1; i<= rows; i++)
{
for (j=1; j<=i; j++)
{
printf("%d ", number);
++number;
}
printf("n");
}
return 0;
}
Output:-
Conclusion:- From this experiment we have learn about C conditional
operator, goto statement and nested loop which are very important for
programming. I think it will help me a lot in practical life

More Related Content

What's hot

Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
THE NORTHCAP UNIVERSITY
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]
Abhishek Sinha
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans incnayakq
 
VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in C
Syed Mustafa
 
Control Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, StructuresControl Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, Structures
indra Kishor
 
Categories for the Working C++ Programmer
Categories for the Working C++ ProgrammerCategories for the Working C++ Programmer
Categories for the Working C++ ProgrammerPlatonov Sergey
 
Interesting facts on c
Interesting facts on cInteresting facts on c
Interesting facts on c
Durgadevi palani
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
Functions
FunctionsFunctions
Functions
Jesmin Akhter
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c language
MomenMostafa
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
Sujata Regoti
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
programming9
 
CP Handout#8
CP Handout#8CP Handout#8
CP Handout#8
trupti1976
 
Function & Recursion in C
Function & Recursion in CFunction & Recursion in C
Function & Recursion in C
Aditya Nihal Kumar Singh
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
Zaibi Gondal
 
C programming Lab 2
C programming Lab 2C programming Lab 2
C programming Lab 2
Zaibi Gondal
 
Lập trình C
Lập trình CLập trình C
Lập trình C
Viet NguyenHoang
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
Chris Ohk
 
Functions in C
Functions in CFunctions in C
Functions in C
Princy Nelson
 

What's hot (20)

Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in C
 
Control Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, StructuresControl Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, Structures
 
Categories for the Working C++ Programmer
Categories for the Working C++ ProgrammerCategories for the Working C++ Programmer
Categories for the Working C++ Programmer
 
Interesting facts on c
Interesting facts on cInteresting facts on c
Interesting facts on c
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Functions
FunctionsFunctions
Functions
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c language
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
CP Handout#8
CP Handout#8CP Handout#8
CP Handout#8
 
Function & Recursion in C
Function & Recursion in CFunction & Recursion in C
Function & Recursion in C
 
C programming slide c03
C programming slide c03C programming slide c03
C programming slide c03
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
C programming Lab 2
C programming Lab 2C programming Lab 2
C programming Lab 2
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
 
Functions in C
Functions in CFunctions in C
Functions in C
 

Similar to 175035 cse lab-05

C language
C languageC language
C language
Priya698357
 
Understand more about C
Understand more about CUnderstand more about C
Understand more about C
Yi-Hsiu Hsu
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
Tushar B Kute
 
Function recap
Function recapFunction recap
Function recapalish sha
 
Function recap
Function recapFunction recap
Function recapalish sha
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
Abhishekkumarsingh630054
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
msharshitha03s
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
JavvajiVenkat
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143
alish sha
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
Umesh Nikam
 
Array Cont
Array ContArray Cont
Some stuff about C++ and development
Some stuff about C++ and developmentSome stuff about C++ and development
Some stuff about C++ and development
Jon Jagger
 
Fundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptxFundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptx
Chandrakant Divate
 
Function in c program
Function in c programFunction in c program
Function in c program
umesh patil
 
Embedded C - Day 2
Embedded C - Day 2Embedded C - Day 2
Functions struct&union
Functions struct&unionFunctions struct&union
Functions struct&union
UMA PARAMESWARI
 
7 functions
7  functions7  functions
7 functions
MomenMostafa
 

Similar to 175035 cse lab-05 (20)

C language
C languageC language
C language
 
Understand more about C
Understand more about CUnderstand more about C
Understand more about C
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
Function recap
Function recapFunction recap
Function recap
 
Function recap
Function recapFunction recap
Function recap
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
pointers 1
pointers 1pointers 1
pointers 1
 
functions
functionsfunctions
functions
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
 
Array Cont
Array ContArray Cont
Array Cont
 
Some stuff about C++ and development
Some stuff about C++ and developmentSome stuff about C++ and development
Some stuff about C++ and development
 
Fundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptxFundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptx
 
Function in c program
Function in c programFunction in c program
Function in c program
 
Embedded C - Day 2
Embedded C - Day 2Embedded C - Day 2
Embedded C - Day 2
 
Functions struct&union
Functions struct&unionFunctions struct&union
Functions struct&union
 
7 functions
7  functions7  functions
7 functions
 

More from Mahbubay Rabbani Mim

Effect of density of the fiber on calculating the properties of textile compo...
Effect of density of the fiber on calculating the properties of textile compo...Effect of density of the fiber on calculating the properties of textile compo...
Effect of density of the fiber on calculating the properties of textile compo...
Mahbubay Rabbani Mim
 
Presentation about Core Spun Yarn.pptx
Presentation about Core Spun Yarn.pptxPresentation about Core Spun Yarn.pptx
Presentation about Core Spun Yarn.pptx
Mahbubay Rabbani Mim
 
Difference among 8085,8086,80186,80286,80386 Microprocessor.pdf
Difference among 8085,8086,80186,80286,80386 Microprocessor.pdfDifference among 8085,8086,80186,80286,80386 Microprocessor.pdf
Difference among 8085,8086,80186,80286,80386 Microprocessor.pdf
Mahbubay Rabbani Mim
 
Fsd lab 01 study on woven fabric analysis
Fsd lab 01 study on woven fabric analysisFsd lab 01 study on woven fabric analysis
Fsd lab 01 study on woven fabric analysis
Mahbubay Rabbani Mim
 
Water repellent lab report by mim
Water repellent lab report by mimWater repellent lab report by mim
Water repellent lab report by mim
Mahbubay Rabbani Mim
 
Presentation on Plain Weave and some Elementary terms of Textilel Design
Presentation on Plain Weave and some Elementary terms of Textilel DesignPresentation on Plain Weave and some Elementary terms of Textilel Design
Presentation on Plain Weave and some Elementary terms of Textilel Design
Mahbubay Rabbani Mim
 
Wet process lab 02 on Resin Finish treatment for wrinkle free
Wet process lab 02 on Resin Finish treatment for wrinkle freeWet process lab 02 on Resin Finish treatment for wrinkle free
Wet process lab 02 on Resin Finish treatment for wrinkle free
Mahbubay Rabbani Mim
 
175035 apparel lab 03 asad sir
175035 apparel lab 03 asad sir175035 apparel lab 03 asad sir
175035 apparel lab 03 asad sir
Mahbubay Rabbani Mim
 
175035 apparel lab 02 asad sir
175035 apparel lab 02 asad sir175035 apparel lab 02 asad sir
175035 apparel lab 02 asad sir
Mahbubay Rabbani Mim
 
175035 apparel lab 01 asad sir
175035 apparel lab 01 asad sir175035 apparel lab 01 asad sir
175035 apparel lab 01 asad sir
Mahbubay Rabbani Mim
 
175035 apparel lab 05 asad sir
175035 apparel lab 05 asad sir175035 apparel lab 05 asad sir
175035 apparel lab 05 asad sir
Mahbubay Rabbani Mim
 
175035 apparel lab 04 asad sir
175035 apparel lab 04 asad sir175035 apparel lab 04 asad sir
175035 apparel lab 04 asad sir
Mahbubay Rabbani Mim
 
175035 apparel assignment cutting
175035 apparel assignment cutting175035 apparel assignment cutting
175035 apparel assignment cutting
Mahbubay Rabbani Mim
 
175035 spss lab-01
175035 spss lab-01175035 spss lab-01
175035 spss lab-01
Mahbubay Rabbani Mim
 
175035 apparel lab 01
175035 apparel lab 01175035 apparel lab 01
175035 apparel lab 01
Mahbubay Rabbani Mim
 
175035 apparel lab 03
175035 apparel lab 03175035 apparel lab 03
175035 apparel lab 03
Mahbubay Rabbani Mim
 
175035 apparel lab 03
175035 apparel lab 03175035 apparel lab 03
175035 apparel lab 03
Mahbubay Rabbani Mim
 
175035 apparel lab 04
175035 apparel lab 04175035 apparel lab 04
175035 apparel lab 04
Mahbubay Rabbani Mim
 
175035-cse LAB-04
175035-cse LAB-04 175035-cse LAB-04
175035-cse LAB-04
Mahbubay Rabbani Mim
 
175035 act lab 04
175035 act lab 04175035 act lab 04
175035 act lab 04
Mahbubay Rabbani Mim
 

More from Mahbubay Rabbani Mim (20)

Effect of density of the fiber on calculating the properties of textile compo...
Effect of density of the fiber on calculating the properties of textile compo...Effect of density of the fiber on calculating the properties of textile compo...
Effect of density of the fiber on calculating the properties of textile compo...
 
Presentation about Core Spun Yarn.pptx
Presentation about Core Spun Yarn.pptxPresentation about Core Spun Yarn.pptx
Presentation about Core Spun Yarn.pptx
 
Difference among 8085,8086,80186,80286,80386 Microprocessor.pdf
Difference among 8085,8086,80186,80286,80386 Microprocessor.pdfDifference among 8085,8086,80186,80286,80386 Microprocessor.pdf
Difference among 8085,8086,80186,80286,80386 Microprocessor.pdf
 
Fsd lab 01 study on woven fabric analysis
Fsd lab 01 study on woven fabric analysisFsd lab 01 study on woven fabric analysis
Fsd lab 01 study on woven fabric analysis
 
Water repellent lab report by mim
Water repellent lab report by mimWater repellent lab report by mim
Water repellent lab report by mim
 
Presentation on Plain Weave and some Elementary terms of Textilel Design
Presentation on Plain Weave and some Elementary terms of Textilel DesignPresentation on Plain Weave and some Elementary terms of Textilel Design
Presentation on Plain Weave and some Elementary terms of Textilel Design
 
Wet process lab 02 on Resin Finish treatment for wrinkle free
Wet process lab 02 on Resin Finish treatment for wrinkle freeWet process lab 02 on Resin Finish treatment for wrinkle free
Wet process lab 02 on Resin Finish treatment for wrinkle free
 
175035 apparel lab 03 asad sir
175035 apparel lab 03 asad sir175035 apparel lab 03 asad sir
175035 apparel lab 03 asad sir
 
175035 apparel lab 02 asad sir
175035 apparel lab 02 asad sir175035 apparel lab 02 asad sir
175035 apparel lab 02 asad sir
 
175035 apparel lab 01 asad sir
175035 apparel lab 01 asad sir175035 apparel lab 01 asad sir
175035 apparel lab 01 asad sir
 
175035 apparel lab 05 asad sir
175035 apparel lab 05 asad sir175035 apparel lab 05 asad sir
175035 apparel lab 05 asad sir
 
175035 apparel lab 04 asad sir
175035 apparel lab 04 asad sir175035 apparel lab 04 asad sir
175035 apparel lab 04 asad sir
 
175035 apparel assignment cutting
175035 apparel assignment cutting175035 apparel assignment cutting
175035 apparel assignment cutting
 
175035 spss lab-01
175035 spss lab-01175035 spss lab-01
175035 spss lab-01
 
175035 apparel lab 01
175035 apparel lab 01175035 apparel lab 01
175035 apparel lab 01
 
175035 apparel lab 03
175035 apparel lab 03175035 apparel lab 03
175035 apparel lab 03
 
175035 apparel lab 03
175035 apparel lab 03175035 apparel lab 03
175035 apparel lab 03
 
175035 apparel lab 04
175035 apparel lab 04175035 apparel lab 04
175035 apparel lab 04
 
175035-cse LAB-04
175035-cse LAB-04 175035-cse LAB-04
175035-cse LAB-04
 
175035 act lab 04
175035 act lab 04175035 act lab 04
175035 act lab 04
 

Recently uploaded

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
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
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
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
 
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
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
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
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
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
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 

Recently uploaded (20)

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
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
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
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
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.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
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
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
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 

175035 cse lab-05

  • 1. Lab Report Course ID: TE-3702 Course Title:-Computer Application and Programming (Sessional) Experiment No. 05 Name:-Introduction to C conditional operator, nested loop and go to statement. Submitted by Name : ID : Year and Semester : Session : Department : Mahbubay Rabbani 175035 3/1 2018-19 Textile Engineering Submitted to Khawja Imran Masud Lecturer Department of CSE Dhaka University of Engineering & Technology (DUET), Gazipur
  • 2. Introduction:- The conditional statements are the decision-making statements which depends upon the output of the expression. A loop inside another loop is called a nested loop. The goto statement is a jump statement which is sometimes also called unconditional jump statement. The goto statement can be used to jump from anywhere to anywhere within a function. Objectives:-  To know about conditional operator.  To know about nested loop.  To know about “goto” statement.
  • 3. Conditional Operator Conditional statements are decision-making statements that depend on the output of the expression. It is represented by two symbols that are '?' and ':'. It works on three operands and that’s why it is also called the ternary operator. The behavior of the conditional operator is similar to the 'if-else' statement as 'if-else' statement is also a decision-making statement. This helps the ternary operator to think of it as a shorthand way to write a statement. The ternary operator works with the 3 following principles:-  The first is a comparison argument  The second is upon the results of true comparisons  The third results in a false comparison
  • 4. Example:- C program to check student result using conditional operator Input:- #include <stdio.h> int main() { int mark; printf("Enter the mark="); scanf("%d", &mark); puts(mark>=40?"Pass":"Fail"); return 0; }
  • 6. Nested loop A loop inside another loop is called a nested loop. The depth of nested loop depends on the complexity of a problem. Using a for loop within another for loop is called nested for loop. In nested for loop one or more statements can be included in the body of the loop. Example:- Input:- #include <stdio.h> int main() { int a, b; for(a=1;a<=5;a++) { for(b=1;b<=5;b++) { printf("%d ",b); } printf("n"); } return 0; }
  • 8. go to statement The goto statement is a jump statement which is sometimes called unconditional jump statement. The goto statement can be used to jump from anywhere to anywhere within a function. Here a label is used which is a user-defined identifier and indicates the target statement. It can be set anywhere in the C program above or below to goto statement. Example Write a C program that take the any double numbers between 1 to 10 and calculate the square root of that number. input:- #include<stdio.h> int main() { double x,y; read: printf("Enter the double number between 1 to 10="); scanf("%lf", &x); if(x<0 || x>10) goto read ; y=sqrt(x); printf( "%lf",y); return 0; }
  • 10. Home task problems:- Problem:- Find the largest number among 3 input numbers using conditional operator. Input:- # include <stdio.h> int main() { int a, b, c, large ; printf("Enter 1st number="); scanf("%d",&a); printf("Enter 2nd number="); scanf("%d",&b); printf("Enter 3rd number="); scanf("%d",&c); large = a > b ? (a > c ? a : c) : (b > c ? b : c) ; printf("The largest number is=%d",large); }
  • 12. Problem:- Write a C program that display half Pyramid of * * * * * * * * * * * * * * * * Input:- #include <stdio.h> int main() { int i, j, rows; printf("Enter the number of rows: "); scanf("%d", &rows); for (i = 1; i <= rows; i++) { for (j = 1; j <= i; j++) { printf("* "); } printf("n"); } return 0; }
  • 14. Problem:- Write a C program that display Half Pyramid of Numbers 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 Input:- #include <stdio.h> int main() { int i,j,rows; printf("Enter the number of rows="); scanf("%d", &rows); for(i=1; i<=rows; i++) {for (j=1; j<=i; j++) { printf("%d",j); } printf("n"); } return 0;}
  • 16. Problem:- Write a C program that display Inverted Half Pyramid of * * * * * * * * * * * * * * * * Input:- #include <stdio.h> int main() { int i,j,rows; printf("Enter the number of rows="); scanf("%d", &rows); for(i=rows; i>=1; i--) {for (j=1; j<=i; j++) { printf("*"); } printf("n"); } return 0; }
  • 18. Lab Assessment:- Problem:- Write a C program that displays Inverted Half Pyramid of Number. 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 Input: 5 Input:- #include <stdio.h> int main() { int i,j,rows; printf("Enter the number of rows="); scanf("%d", &rows); for(i=rows; i>=1; i--) {for (j=1; j<=i; j++) { printf("%d",j); } printf("n"); }
  • 20. Problem:- Write a C program that display the pattern given below. 1 2 3 4 5 6 7 8 9 10 Input: 4 Input:- #include <stdio.h> int main() { int rows, i, j, number = 1; printf("Enter the number of rows= "); scanf("%d", &rows); for (i=1; i<= rows; i++) { for (j=1; j<=i; j++) { printf("%d ", number); ++number; } printf("n"); }
  • 22. Conclusion:- From this experiment we have learn about C conditional operator, goto statement and nested loop which are very important for programming. I think it will help me a lot in practical life