0% found this document useful (0 votes)
16 views4 pages

5th Chapter

The document contains examples of C programs demonstrating different loops and conditional statements: 1. For loops are used to print statements repeatedly a fixed number of times. While loops check a condition and repeat until the condition becomes false. Do-while loops execute the body at least once and then check the condition. 2. Conditional statements like if-else are used to check conditions and execute different code blocks based on whether the condition is true or false. 3. Examples include programs to calculate average, area of circle, temperature conversion, checking positive/negative/zero numbers, and printing patterns using different loops.

Uploaded by

Fahim Ahammed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

5th Chapter

The document contains examples of C programs demonstrating different loops and conditional statements: 1. For loops are used to print statements repeatedly a fixed number of times. While loops check a condition and repeat until the condition becomes false. Do-while loops execute the body at least once and then check the condition. 2. Conditional statements like if-else are used to check conditions and execute different code blocks based on whether the condition is true or false. 3. Examples include programs to calculate average, area of circle, temperature conversion, checking positive/negative/zero numbers, and printing patterns using different loops.

Uploaded by

Fahim Ahammed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

১। গড় । {

C Program: float c,f;


#include <stdio.h> printf("Enter the farenheight value: ");
int main() scanf("%f",&f);
{ c=(5*f-160)/9;
int a, b, c, d, sum, avg; printf("%f",c);
a=45; return 0;
b=34; }
c=47; Output:
d=64; Enter the farenheight value: 94.6
sum = a+b+c+d; 34.777779
avg= sum/4;
৪। ও
printf("%d",avg);

return 0;
C Program:
}
#include <stdio.h>
Output: 47
int main()
২। {
। float base, height, area;
C Program: printf("Enter value for base and height: ");
#include <stdio.h> scanf("%f %f",&base, &height);
int main() area=0.5*base*height;
{ printf("%f",area);
float c,f; return 0;
printf("Enter the centigrade value: "); }
scanf("%f",&c); Output:
f=(9*c+160)/5; Enter value for base and height: 23 56.7
printf("%f",f); 652.049988
return 0;
৫।
}

Output:
C Program:
Enter the centigrade value: 34.67
#include <stdio.h>
94.405998
int main()
৩। {
। int a,b,c;
C Program; float s, area;
#include <stdio.h> printf("Enter the value of three arms: ");
int main() scanf("%d %d %d",&a, &b, &c);

Dream DU Private Preparation Programme (ICT - 5th Chapter_part-2) Page 1


s=(a+b+c)/2; Output:
area=sqrt(s*(s-a)*(s-b)*(s-c)); Enter a number: 12
printf("%f",area); 12 is EVEN number.
return 0;
Enter a number: 13
}
13 is ODD number.
Output:
Enter the value of three arms: 23 15 12 ৮। ও গ ।
80.622574 C Program;
#include <stdio.h>
৬। ।
int main()
C Program:
{
#include <stdio.h>
int n;
int main()
printf("Enter a number: ");
{
scanf("%d",&n);
float pi=3.1416, r, area;
if(n>0){
printf("Enter the radius of circle: ");
printf("%d is POSITIVE number.",n);
scanf("%f",&r);
}
area=pi*r*r;
else if(n==0){
printf("Area of Circle: %0.2f",area);
printf("%d is ZERO",n);
return 0;
}
}
else{
Output:
printf("%d is NEGATIVE number.",n);
Enter the radius of circle: 12.50
}
Area of Circle: 490.87
return 0;
৭। ড়ও ড় । }
C Program: Output:
#include <stdio.h> Enter a number: 12
int main() 12 is POSITIVE number.
{ Enter a number: -2
int n; -2 is NEGATIVE number.
printf("Enter a number: ");
Enter a number: 0
scanf("%d",&n);
0 is ZERO.
if(n%2==0){
printf("%d is EVEN number.",n); ৯। for Loop

}
1. C Program:
else{
#include <stdio.h>
printf("%d is ODD number.",n);
int main()
}
{
return 0;
int i;
}
for(i=1; i<=5; i++){

Dream DU Private Preparation Programme (ICT - 5th Chapter_part-2) Page 2


printf("Hablu the great \n"); WOW
} WOW
return 0; WOW
} WOW
Output: WOW
Hablu the great 2. C Program:
Hablu the great #include <stdio.h>
Hablu the great int main()
Hablu the great {
Hablu the great int i=1;
2. C program: while (i<=5){
#include <stdio.h> printf("%d \n",i);
int main() i++;
{ }
int i; return 0;
for(i=1; i<=5; i++){ }
printf("%d \n",i); Output:
} 1
return 0; 2
} 3
Output: 4
1 5
2 ১১। Do-loop Statement
3 ।
4 1. C Program:
5 #include <stdio.h>
১০। While Statement int main()
। {
1. C program: int i=1;
#include <stdio.h> do{
int main() printf("Kabila \n");
{ i++;
int i=1; }
while (i<=5){ while(i<=4);
printf("WOW \n"); return 0;
i++; }
} Output:
return 0; Kabila
} Kabila

Output: Kabila
Kabila

Dream DU Private Preparation Programme (ICT - 5th Chapter_part-2) Page 3


Av‡Lix gIKv
১। ।
২। ।
৩। ।
৪। ড় ।
৫। ।
৬। ।
৭। ।
৮। ও ;
৯। ড় ড় ।
১০। for loop, while loop. do--while loop ।

Dream DU Private Preparation Programme (ICT - 5th Chapter_part-2) Page 4

You might also like