SlideShare une entreprise Scribd logo
1  sur  4
/* Write a C program to calculate the following Sum
* Sum=1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10!
*/


#include <stdio.h>

#include <math.h>



void main()

{

int counter,f_coun;

float sum=0,x,power,fact;

printf("<-----------------------PROGRAM FOR SUM OF EQ. SERIES----------------------->");

printf("nntEQUATION SERIES : 1- X^2/2! + X^4/4! - X^6/6! + X^8/8! - X^10/10!");



printf("nnntENTER VALUE OF X : ");

scanf("%f",&x);



for(counter=0, power=0; power<=10; counter++,power=power+2)

{

fact=1;

//CALC FACTORIAL OF POWER VALUE

for(f_coun=power; f_coun>=1; f_coun--)

     fact *= f_coun;

//EQ. FOR SUM SERIES
sum=sum+(pow(-1,counter)*(pow(x,power)/fact));

}



printf("SUM : %f",sum);



}




Prime numbers:
#include<stdio.h>

main()

{

int no, counter,counter1,check;

printf("<----------------------PRIME NO. SERIES------------------>");

printf("nnnttt INPUT THE VALUE OF N:");

scanf("%d",&no);

printf("nn THE PRIME No.SERIES B/W 1 TO %d:nn",no);

for(counter=1;counter<=no;counter++)

{

check =0;

for(counter1=counter-1;counter>1;counter--)

         if(counter%counter==0)

{

check++;

break;
}

if(check==0)

printf("%dt",counter);

            }

}




/* Write a C program toe find the roots of a quadratic equation.
*/


#include<stdio.h>

#include<conio.h>

#include<math.h>



void main()

{

float a,b,c,root1,root2;

clrscr();

printf("n Enter values of a,b,c for finding roots of a quadratic eq:n");

scanf("%f%f%f",&a,&b,&c);



/*checking condition*/

if(b*b>4*a*c)

{

root1=-b+sqrt(b*b-4*a*c)/2*a;
root2=-b-sqrt(b*b-4*a*c)/2*a;

printf("n*****ROOTS ARE*****n");

printf("n root1=%fn root2=%f",root1,root2);

}

else

printf("n Imaginary Roots.");

getch();

}

Contenu connexe

Tendances (20)

week-11x
week-11xweek-11x
week-11x
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
week-10x
week-10xweek-10x
week-10x
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY Mazedur
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
C program to implement linked list using array abstract data type
C program to implement linked list using array abstract data typeC program to implement linked list using array abstract data type
C program to implement linked list using array abstract data type
 
program in c
program in cprogram in c
program in c
 
week-18x
week-18xweek-18x
week-18x
 
Avl tree
Avl treeAvl tree
Avl tree
 
week-4x
week-4xweek-4x
week-4x
 
Final ds record
Final ds recordFinal ds record
Final ds record
 
Progr2
Progr2Progr2
Progr2
 
C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시
 
Computer programing w
Computer programing wComputer programing w
Computer programing w
 
11 1 포인터
11 1 포인터11 1 포인터
11 1 포인터
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
 
C++ programs
C++ programsC++ programs
C++ programs
 
week-15x
week-15xweek-15x
week-15x
 
C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 

Similaire à week-2x (20)

week-3x
week-3xweek-3x
week-3x
 
Lab 2
Lab 2Lab 2
Lab 2
 
C programs
C programsC programs
C programs
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 
Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods
 
Assignment no39
Assignment no39Assignment no39
Assignment no39
 
Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
 
C programs
C programsC programs
C programs
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
C file
C fileC file
C file
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
Write a program that reads in integer as many as the user enters from.docx
Write a program that reads in integer as many as the user enters from.docxWrite a program that reads in integer as many as the user enters from.docx
Write a program that reads in integer as many as the user enters from.docx
 
C language program
C language programC language program
C language program
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
Tu1
Tu1Tu1
Tu1
 

Plus de KITE www.kitecolleges.com (20)

DISTRIBUTED INTERACTIVE VIRTUAL ENVIRONMENT
DISTRIBUTED INTERACTIVE VIRTUAL ENVIRONMENTDISTRIBUTED INTERACTIVE VIRTUAL ENVIRONMENT
DISTRIBUTED INTERACTIVE VIRTUAL ENVIRONMENT
 
BrainFingerprintingpresentation
BrainFingerprintingpresentationBrainFingerprintingpresentation
BrainFingerprintingpresentation
 
ch6
ch6ch6
ch6
 
PPT (2)
PPT (2)PPT (2)
PPT (2)
 
ch14
ch14ch14
ch14
 
ch16
ch16ch16
ch16
 
holographic versatile disc
holographic versatile discholographic versatile disc
holographic versatile disc
 
week-22x
week-22xweek-22x
week-22x
 
week-16x
week-16xweek-16x
week-16x
 
week-5x
week-5xweek-5x
week-5x
 
week-6x
week-6xweek-6x
week-6x
 
ch8
ch8ch8
ch8
 
Intro Expert Systems test-me.co.uk
Intro Expert Systems test-me.co.ukIntro Expert Systems test-me.co.uk
Intro Expert Systems test-me.co.uk
 
ch17
ch17ch17
ch17
 
ch4
ch4ch4
ch4
 
week-7x
week-7xweek-7x
week-7x
 
week-9x
week-9xweek-9x
week-9x
 
week-14x
week-14xweek-14x
week-14x
 
AIRBORNE
AIRBORNEAIRBORNE
AIRBORNE
 
ch2
ch2ch2
ch2
 

Dernier

4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Celine George
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 

Dernier (20)

4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 

week-2x

  • 1. /* Write a C program to calculate the following Sum * Sum=1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10! */ #include <stdio.h> #include <math.h> void main() { int counter,f_coun; float sum=0,x,power,fact; printf("<-----------------------PROGRAM FOR SUM OF EQ. SERIES----------------------->"); printf("nntEQUATION SERIES : 1- X^2/2! + X^4/4! - X^6/6! + X^8/8! - X^10/10!"); printf("nnntENTER VALUE OF X : "); scanf("%f",&x); for(counter=0, power=0; power<=10; counter++,power=power+2) { fact=1; //CALC FACTORIAL OF POWER VALUE for(f_coun=power; f_coun>=1; f_coun--) fact *= f_coun; //EQ. FOR SUM SERIES
  • 2. sum=sum+(pow(-1,counter)*(pow(x,power)/fact)); } printf("SUM : %f",sum); } Prime numbers: #include<stdio.h> main() { int no, counter,counter1,check; printf("<----------------------PRIME NO. SERIES------------------>"); printf("nnnttt INPUT THE VALUE OF N:"); scanf("%d",&no); printf("nn THE PRIME No.SERIES B/W 1 TO %d:nn",no); for(counter=1;counter<=no;counter++) { check =0; for(counter1=counter-1;counter>1;counter--) if(counter%counter==0) { check++; break;
  • 3. } if(check==0) printf("%dt",counter); } } /* Write a C program toe find the roots of a quadratic equation. */ #include<stdio.h> #include<conio.h> #include<math.h> void main() { float a,b,c,root1,root2; clrscr(); printf("n Enter values of a,b,c for finding roots of a quadratic eq:n"); scanf("%f%f%f",&a,&b,&c); /*checking condition*/ if(b*b>4*a*c) { root1=-b+sqrt(b*b-4*a*c)/2*a;
  • 4. root2=-b-sqrt(b*b-4*a*c)/2*a; printf("n*****ROOTS ARE*****n"); printf("n root1=%fn root2=%f",root1,root2); } else printf("n Imaginary Roots."); getch(); }