0% found this document useful (0 votes)
45 views

Introduction To Computer Programming (Cse-271) : Prepared by Md. Atiqul Islam Rizvi Lecturer, Dept. of Cse, Cuet

The document discusses three methods for swapping two variables in C programming: 1) Using three variables, where a temporary variable is used to store one value while the other two variables are swapped. 2) Using two variables, where the values are swapped by adding one value to the other and subtracting parts of the expression. 3) The introduction discusses programming concepts like exponential, sine, and cosine series expansions in C using functions to calculate their values.

Uploaded by

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

Introduction To Computer Programming (Cse-271) : Prepared by Md. Atiqul Islam Rizvi Lecturer, Dept. of Cse, Cuet

The document discusses three methods for swapping two variables in C programming: 1) Using three variables, where a temporary variable is used to store one value while the other two variables are swapped. 2) Using two variables, where the values are swapped by adding one value to the other and subtracting parts of the expression. 3) The introduction discusses programming concepts like exponential, sine, and cosine series expansions in C using functions to calculate their values.

Uploaded by

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

INTRODUCTION TO COMPUTER

PROGRAMMING (CSE-271)
PREPARED BY
MD. ATIQUL ISLAM RIZVI
LECTURER, DEPT. OF CSE, CUET.
Series
#include<stdio.h>
float eseries(float, int)  e^x = 1 + x + x 2
/2! + x 3
/3! ........
int main() {
    int n; float x;
    scanf("%f", &x);
    scanf("%d", &n);
      float eseries(float x, int n) {
    printf("\nThe Exponential series value of int i; float t=1, sum=1;
%f = %0.4f", x, eseries(x, n)); for(i=1; i<=n; i++) {
}          t = t*x/i;
         sum = sum+t;
     }
return sum;
}
Series
#include<stdio.h> sin x = x - x3/3! + x5/5! - x7/7! + x9/9! ........
float sineseries(float, int) float sineseries(float x, int n) {
long long fact(int)  int i; float t, sum;
int main() { t = x; sum = x;
    int n; float x; for(i=1; i<=n; i++) {
    scanf("%f", &x);          t = (t*(-1)*x*x)/fact(2*i + 1));
    scanf("%d", &n);          sum = sum+t;
     //x = x*(3.1415/180);      }
    printf("\nThe Sine series value of return sum;
%f = %0.4f", x, sineseries(x, n)); }
} long long fact(int n) {
long long f =1; int i;
for(i=1; i<=n; i++) {
f = f * i; }
return f;
}
Series
#include<stdio.h> cos x = 1 - x2/2! + x4/4! – x6/6! + x8/8! ........
float cosineseries(float, int) float cosineseries(float x, int n) {
long long fact(int)   int i; float t, sum;
int main() { t = 1; sum = 1;
    int n; float x; for(i=1; i<=n; i++) {
    scanf("%f", &x);          t = (t*(-1)*x*x)/fact(2*i));
    scanf("%d", &n);          sum = sum+t;
     //x = x*(3.1415/180);      }
    printf("\nThe Sine series value of return sum;
%f = %0.4f", x, cosineseries(x, n)); }
} long long fact(int n) {
long long f =1; int i;
for(i=1; i<=n; i++) {
f = f * i; }
return f;
}
Swap
 Uses two variable
 Uses three variable
#include<stdio.h>
#include<stdio.h>
int main() {
int main() {
    int n, x;
    int n, x, temp;
    scanf("%d %d", &n, &x);
    scanf("%d %d", &n, &x);
    printf(“Before swap, n = %d, x =
    printf(“Before swap, n = %d, x =
%d", n, x);
%d", n, x);
n = n + x; //*
temp = n; n = x; x = temp;
x = n – x; //,/
printf(“After swap, n = %d, x =
n = n – x; //,/
%d", n, x);
printf(“After swap, n = %d, x = %d",
}
n, x);
}

You might also like