SlideShare a Scribd company logo
1 of 13
Md. Mazedur Rahman
ID : 07
Section :A
PRESENTED BY
C Programe
#include<stdio.h>
#include<math.h> //for sqrt() function
main()
{
float a,b,c,dis,r1,r2;//a,b,c are constant coefficients, dis= discriminant and r1,r2 are roots
printf ("nQuadratic Equation is of the form: ax^2 + bx + c = 0 n");
printf("nEnter the values of a, b and c: ");
scanf("%f %f %f",&a,&b,&c);
dis = pow(b,2) - 4*a*c; // calculation of discriminant
if(dis < 0) //checking the value of discriminant
{
printf("nThe roots are imaginary.nn");
printf("Root1= %.3f % + .3fi",-b/(2*a),sqrt(-dis)/(2*a));
printf("nRoot2= %.3f %+ .3fin",-b/(2*a),-sqrt(-dis)/(2*a));
}
1. QUADRATIC EQUATION
else
{
r1 = (-b + sqrt(dis))/(2.0*a);
r2 = (-b - sqrt(dis))/(2.0*a);
printf("nThe first root is = %fnThe second root is = %fn",r1,r2);
}
return 0;
}
OUTPUT
1. QUADRATIC EQUATION
#include<stdio.h>
int main()
{
float fahrenheit, celsius;
//get the limit of fibonacci series
printf("Enter Fahrenheit: n");
scanf("%f",&fahrenheit);
celsius = (fahrenheit - 32)*5/9;
printf("Celsius: %f n", celsius);
return 0;
}
OUTPUT
Enter Fahrenheit:
100
Celsius: 37.777779
2/ FAH TO CEL
This is it, t
#include <stdio.h>
int main()
{
double n1, n2, n3;
printf("Enter three numbers: ");
scanf("%lf %lf %lf", &n1, &n2, &n3);
if (n1>=n2)
{
if(n1>=n3)
printf("%.2lf is the largest number.", n1);
else printf("%.2lf is the largest number.", n3);
}
else
{
if(n2>=n3)
printf("%.2lf is the largest number.", n2);
5. Largest Number
else
printf("%.2lf is the largest number.",n3);
}
return 0;
}
OUTPUT
Enter the number : 10,15,20
The largest number is : 20
#include<stdio.h>
#include<conio.h>
void main()
{
double n,sum=0,i;
clrscr();
printf("n Please Give The Value of N: ");
scanf("%lf",&n);
for(i=1;i<=n;i++)
{
sum = sum + (1/i);
if(i==1)
printf("n 1 +");
elseif(i==n)
printf(" (1/%d) ",i);
7. Harmonic series
else printf(" (1/%d) + ",i);
}
printf("nn THE SUM OF THIS SERIES IS %.2lf",sum); getch();
}
Output
Please Give The Value of N: 5
1 + (1/2) + (1/3) + (1/4) + (1/5)
THE SUM OF THIS SERIES IS 2.28
8. Leap Year
#include <stdio.h>
int main()
{
int year;
printf("Enter a year: ");
scanf("%d",&year);
if(year%4 == 0)
{
if( year%100 == 0)
{
if ( year%400 == 0)
printf("%d is a leap year.", year);
else
printf("%d is not a leap year.", year);
8. Leap Year
}
else
printf("%d is a leap year.", year );
}
else
printf("%d is not a leap year.", year);
return 0;
}
Output
Enter a year: 1900
1900 is not a leap year.
18. Area of Circle
#include<stdio.h>
int main() {
float radius, area;
printf("nEnter the radius of Circle : ");
scanf("%d", &radius);
area = 3.14 * radius * radius;
printf("nArea of Circle : %f", area);
return (0);
} Output
Enter the radius of Circle : 2.0
Area of Circle : 6.14
14. Factorial
#include <stdio.h>
int main()
{
int c, n, fact = 1;
printf("Enter a number to calculate it's factorialn");
scanf("%d", &n);
for (c = 1; c <= n; c++)
fact = fact * c;
printf("Factorial of %d = %dn", n, fact);
return 0;
}
14. Factorial
OUTPUT

More Related Content

What's hot

(Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ (Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ Eli Diaz
 
(Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ (Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ Eli Diaz
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersDr. Loganathan R
 
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันWarawut
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given numberMainak Sasmal
 
Runge kutta C programme
Runge kutta C programmeRunge kutta C programme
Runge kutta C programmeShah Keval
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given numberMainak Sasmal
 
Implementation of strassens
Implementation of  strassensImplementation of  strassens
Implementation of strassensVikash Dhal
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.Dr. Loganathan R
 
programa suma y multiplica
programa suma y multiplicaprograma suma y multiplica
programa suma y multiplicaMaria Amaro
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Hazrat Bilal
 

What's hot (18)

(Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ (Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++
 
(Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ (Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
program in c
program in cprogram in c
program in c
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
 
Aggregate
AggregateAggregate
Aggregate
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Switch
SwitchSwitch
Switch
 
Runge kutta C programme
Runge kutta C programmeRunge kutta C programme
Runge kutta C programme
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Implementation of strassens
Implementation of  strassensImplementation of  strassens
Implementation of strassens
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
 
programa suma y multiplica
programa suma y multiplicaprograma suma y multiplica
programa suma y multiplica
 
Progr2
Progr2Progr2
Progr2
 
C file
C fileC file
C file
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.
 
Pointers
PointersPointers
Pointers
 

Similar to C programming BY Mazedur

Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
C basics
C basicsC basics
C basicsMSc CST
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using CBilal Mirza
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robinAbdullah Al Naser
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSKavyaSharma65
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C CodeSyed Ahmed Zaki
 
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 RobinShariful Haque Robin
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMSaraswathiRamalingam
 
Simple C programs
Simple C programsSimple C programs
Simple C programsab11cs001
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8Rumman Ansari
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
 

Similar to C programming BY Mazedur (20)

Cpds lab
Cpds labCpds lab
Cpds lab
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
C basics
C basicsC basics
C basics
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
 
Cpl
CplCpl
Cpl
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
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
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 

Recently uploaded

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 

Recently uploaded (20)

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 

C programming BY Mazedur

  • 1. Md. Mazedur Rahman ID : 07 Section :A PRESENTED BY C Programe
  • 2. #include<stdio.h> #include<math.h> //for sqrt() function main() { float a,b,c,dis,r1,r2;//a,b,c are constant coefficients, dis= discriminant and r1,r2 are roots printf ("nQuadratic Equation is of the form: ax^2 + bx + c = 0 n"); printf("nEnter the values of a, b and c: "); scanf("%f %f %f",&a,&b,&c); dis = pow(b,2) - 4*a*c; // calculation of discriminant if(dis < 0) //checking the value of discriminant { printf("nThe roots are imaginary.nn"); printf("Root1= %.3f % + .3fi",-b/(2*a),sqrt(-dis)/(2*a)); printf("nRoot2= %.3f %+ .3fin",-b/(2*a),-sqrt(-dis)/(2*a)); } 1. QUADRATIC EQUATION
  • 3. else { r1 = (-b + sqrt(dis))/(2.0*a); r2 = (-b - sqrt(dis))/(2.0*a); printf("nThe first root is = %fnThe second root is = %fn",r1,r2); } return 0; } OUTPUT 1. QUADRATIC EQUATION
  • 4. #include<stdio.h> int main() { float fahrenheit, celsius; //get the limit of fibonacci series printf("Enter Fahrenheit: n"); scanf("%f",&fahrenheit); celsius = (fahrenheit - 32)*5/9; printf("Celsius: %f n", celsius); return 0; } OUTPUT Enter Fahrenheit: 100 Celsius: 37.777779 2/ FAH TO CEL This is it, t
  • 5. #include <stdio.h> int main() { double n1, n2, n3; printf("Enter three numbers: "); scanf("%lf %lf %lf", &n1, &n2, &n3); if (n1>=n2) { if(n1>=n3) printf("%.2lf is the largest number.", n1); else printf("%.2lf is the largest number.", n3); } else { if(n2>=n3) printf("%.2lf is the largest number.", n2); 5. Largest Number
  • 6. else printf("%.2lf is the largest number.",n3); } return 0; } OUTPUT Enter the number : 10,15,20 The largest number is : 20
  • 7. #include<stdio.h> #include<conio.h> void main() { double n,sum=0,i; clrscr(); printf("n Please Give The Value of N: "); scanf("%lf",&n); for(i=1;i<=n;i++) { sum = sum + (1/i); if(i==1) printf("n 1 +"); elseif(i==n) printf(" (1/%d) ",i); 7. Harmonic series
  • 8. else printf(" (1/%d) + ",i); } printf("nn THE SUM OF THIS SERIES IS %.2lf",sum); getch(); } Output Please Give The Value of N: 5 1 + (1/2) + (1/3) + (1/4) + (1/5) THE SUM OF THIS SERIES IS 2.28
  • 9. 8. Leap Year #include <stdio.h> int main() { int year; printf("Enter a year: "); scanf("%d",&year); if(year%4 == 0) { if( year%100 == 0) { if ( year%400 == 0) printf("%d is a leap year.", year); else printf("%d is not a leap year.", year);
  • 10. 8. Leap Year } else printf("%d is a leap year.", year ); } else printf("%d is not a leap year.", year); return 0; } Output Enter a year: 1900 1900 is not a leap year.
  • 11. 18. Area of Circle #include<stdio.h> int main() { float radius, area; printf("nEnter the radius of Circle : "); scanf("%d", &radius); area = 3.14 * radius * radius; printf("nArea of Circle : %f", area); return (0); } Output Enter the radius of Circle : 2.0 Area of Circle : 6.14
  • 12. 14. Factorial #include <stdio.h> int main() { int c, n, fact = 1; printf("Enter a number to calculate it's factorialn"); scanf("%d", &n); for (c = 1; c <= n; c++) fact = fact * c; printf("Factorial of %d = %dn", n, fact); return 0; }