SlideShare a Scribd company logo
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
Ad

More Related Content

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++
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
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
Hitesh Kumar
 
program in c
program in cprogram in c
program in c
Tanmay337011
 
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
Dr. Loganathan R
 
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
Warawut
 
Aggregate
AggregateAggregate
Aggregate
Suresh Cse
 
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
Mainak Sasmal
 
Switch
SwitchSwitch
Switch
Ankit Dubey
 
Runge kutta C programme
Runge kutta C programmeRunge kutta C programme
Runge kutta C programme
Shah 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 number
Mainak Sasmal
 
Implementation of strassens
Implementation of  strassensImplementation of  strassens
Implementation of strassens
Vikash 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 multiplica
Maria Amaro
 
Progr2
Progr2Progr2
Progr2
SANTOSH RATH
 
C file
C fileC file
C file
simarsimmygrewal
 
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
 
Pointers
PointersPointers
Pointers
ManjuShanmugam1593
 
(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 pointers
Dr. 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 number
Mainak Sasmal
 
Runge kutta C programme
Runge kutta C programmeRunge kutta C programme
Runge kutta C programme
Shah 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 number
Mainak Sasmal
 
Implementation of strassens
Implementation of  strassensImplementation of  strassens
Implementation of strassens
Vikash 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 multiplica
Maria 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
 

Similar to C programming BY Mazedur (20)

Cpds lab
Cpds labCpds lab
Cpds lab
praveennallavelly08
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
manoj11manu
 
C Programming lab
C Programming labC Programming lab
C Programming lab
Vikram Nandini
 
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
vrgokila
 
C basics
C basicsC basics
C basics
MSc CST
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
Bilal Mirza
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar 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 robin
Abdullah Al Naser
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
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
KavyaSharma65
 
Cpl
CplCpl
Cpl
Ayesha Shariff
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
Syed 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 Robin
Shariful Haque Robin
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
Lakshmi Sarvani Videla
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
ab11cs001
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
happycocoman
 
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
vrgokila
 
C basics
C basicsC basics
C basics
MSc CST
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
Bilal Mirza
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar 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 robin
Abdullah 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 ANSWERS
KavyaSharma65
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
Syed 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 Robin
Shariful Haque Robin
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
ab11cs001
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
happycocoman
 
Ad

Recently uploaded (20)

The Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLabThe Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLab
Journal of Soft Computing in Civil Engineering
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
How to use nRF24L01 module with Arduino
How to use nRF24L01 module with ArduinoHow to use nRF24L01 module with Arduino
How to use nRF24L01 module with Arduino
CircuitDigest
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
inmishra17121973
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
How to use nRF24L01 module with Arduino
How to use nRF24L01 module with ArduinoHow to use nRF24L01 module with Arduino
How to use nRF24L01 module with Arduino
CircuitDigest
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
inmishra17121973
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Ad

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; }