Skip to content

Commit d2a70bc

Browse files
committed
7th May 2018 Update
1 parent de7f704 commit d2a70bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+6453
-68
lines changed

CJC-Programming/first.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/************************************************************************/
2+
/* Name: Towfiqul Islam */
3+
/* uva id: 448714 */
4+
/* email id: towfiq.106@gmail.com */
5+
/* institute: IIUC */
6+
/* address: Chittagong, Bangladesh */
7+
/* */
8+
/************************************************************************/
9+
10+
#include<stdio.h>
11+
int main()
12+
{
13+
printf("Hello wsdgcvhbnm,mnbvcxvbnmorld\n");
14+
return 0;
15+
}

CJC-Programming/plus.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/************************************************************************/
2+
/* Name: Towfiqul Islam */
3+
/* uva id: 448714 */
4+
/* email id: towfiq.106@gmail.com */
5+
/* institute: IIUC */
6+
/* address: Chittagong, Bangladesh */
7+
/* */
8+
/************************************************************************/
9+
10+
#include<stdio.h>
11+
int main()
12+
{
13+
int a,b;
14+
a=20
15+
b=5;
16+
printf("%d",a+b);
17+
return 0;
18+
}

CJC-Programming/s.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/************************************************************************/
2+
/* Name: Towfiqul Islam */
3+
/* uva id: 448714 */
4+
/* email id: towfiq.106@gmail.com */
5+
/* institute: IIUC */
6+
/* address: Chittagong, Bangladesh */
7+
/* */
8+
/************************************************************************/
9+
10+
#include <stdio.h>
11+
12+
int main() {
13+
printf("Hello World");
14+
}

CJC-Programming/strProcess.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/************************************************************************/
2+
/* Name: Towfiqul Islam */
3+
/* uva id: 448714 */
4+
/* email id: towfiq.106@gmail.com */
5+
/* institute: IIUC */
6+
/* address: Chittagong, Bangladesh */
7+
/* */
8+
/************************************************************************/
9+
10+
11+
#include<stdio.h>
12+
13+
14+
int main ()
15+
{
16+
char s[100],u[100];
17+
18+
while(1){
19+
scanf("%s",&s);
20+
//printf("%s",s);
21+
if(s[0] == '#')
22+
return 0;
23+
int i,l;
24+
25+
l=strlen(s);
26+
for(i=0;i<l;i++)
27+
{
28+
if(s[i]>='a' && s[i]<='z')
29+
u[i]=s[i]-'a'+'A';
30+
else
31+
u[i]=s[i]-'A'+'a';
32+
}
33+
u[i]=s[i];
34+
printf("%s\n",u);
35+
36+
}
37+
return 0;
38+
}

CJC-Programming/wtcjc.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/************************************************************************/
2+
/* Name: Towfiqul Islam */
3+
/* uva id: 448714 */
4+
/* email id: towfiq.106@gmail.com */
5+
/* institute: IIUC */
6+
/* address: Chittagong, Bangladesh */
7+
/* */
8+
/************************************************************************/
9+
10+
#include <stdio.h>
11+
int main( )
12+
{
13+
printf("Welcome to CJC");
14+
return 0;
15+
}

Numerical Method/codeofimran1.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/************************************************************************/
2+
/* Name: Towfiqul Islam */
3+
/* uva id: 448714 */
4+
/* email id: towfiq.106@gmail.com */
5+
/* institute: IIUC */
6+
/* address: Chittagong, Bangladesh */
7+
/* */
8+
/************************************************************************/
9+
10+
#include<bits/stdc++.h>
11+
using namespace std;
12+
#define ll int
13+
ll save;
14+
15+
16+
17+
ll myfunction(ll number)
18+
{
19+
if(number==0||number==1)
20+
{
21+
return number;
22+
}
23+
ll start=1;
24+
ll endd=number;
25+
while(start<=endd)
26+
{
27+
ll mid=(start+endd)/2;
28+
if(mid*mid==number)
29+
{
30+
return mid;
31+
}
32+
if(mid*mid<number)
33+
{
34+
start=mid+1;
35+
save=mid;
36+
}
37+
else
38+
{
39+
endd=mid-1;
40+
}
41+
}
42+
return save;
43+
}
44+
int main()
45+
{
46+
ll number;
47+
while(1)
48+
{
49+
ll number,save,save2,minn,maxx,mid;
50+
cout<<"Enter a Number to find its floorsqrt()\t(-1 to exit)\n";
51+
cin>>number;
52+
if(number==-1)break;
53+
cout<<"floorsqrt() of the number is "<<myfunction(number)<<endl<<endl;
54+
}
55+
return 0;
56+
}

Numerical Method/codeofshafee1.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/************************************************************************/
2+
/* Name: Towfiqul Islam */
3+
/* uva id: 448714 */
4+
/* email id: towfiq.106@gmail.com */
5+
/* institute: IIUC */
6+
/* address: Chittagong, Bangladesh */
7+
/* */
8+
/************************************************************************/
9+
10+
#include<bits/stdc++.h>
11+
#define MD 1000000007
12+
#define ll long long
13+
using namespace std;
14+
double fun_fx(double x)
15+
{
16+
double fx=(x*x*x)+(5*x)-10;
17+
return fx;
18+
}
19+
int main()
20+
{
21+
cout<<"\t\t\tBisection method algorithm implementation\n\nfunction f(x)=x^3+5x-10\n";
22+
double a,b;
23+
while(1)
24+
{
25+
cout<<"Enter a and b such as a<b and f(a)*f(b)<0\n";
26+
cin>>a>>b;
27+
double mul=fun_fx(a)*fun_fx(b);
28+
if(a<b && mul<0)
29+
{
30+
break;
31+
}
32+
else
33+
{
34+
cout<<"given a and b not valid! try again :(\n\n";
35+
}
36+
}
37+
double eps;
38+
cout<<"Enter specific tolerance: ";
39+
cin>>eps;
40+
ll i=1;
41+
double mid=(a+b)/2.0;
42+
43+
44+
45+
46+
printf(" i\t a\t\tx(mid)\t\tb\t\tf(a)\t\tf(x(mid))\tf(b)\n");
47+
cout<<"---------------------------------------------------------------------------------------------------------\n";
48+
while(fabs(b-mid)>=eps)
49+
{
50+
printf("%2lld\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",i,a,mid,b,fun_fx(a),fun_fx(mid),fun_fx(b));
51+
if(fun_fx(mid)*fun_fx(b)<0)
52+
{
53+
a=mid;
54+
}
55+
else if(fun_fx(a)*fun_fx(mid)<0)
56+
{
57+
b=mid;
58+
}
59+
mid=(a+b)/2.0;
60+
i++;
61+
}
62+
cout<<"Error: "<<fabs(b-mid)<<endl;
63+
return 0;
64+
}

Numerical Method/codeofuk1.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/************************************************************************/
2+
/* Name: Towfiqul Islam */
3+
/* uva id: 448714 */
4+
/* email id: towfiq.106@gmail.com */
5+
/* institute: IIUC */
6+
/* address: Chittagong, Bangladesh */
7+
/* */
8+
/************************************************************************/
9+
10+
11+
#include<iostream>
12+
#include<cmath>
13+
#include<iomanip>
14+
using namespace std;
15+
double f(double x);
16+
double f(double x)
17+
{
18+
double a=pow(x,3)-x-11.0;
19+
return a;
20+
}
21+
int main()
22+
{
23+
cout.precision(4);
24+
cout.setf(ios::fixed);
25+
double a,b,c,e,fa,fb,fc;
26+
a:cout<<"Enter the initial guesses:\na=";
27+
cin>>a;
28+
cout<<"\nb=";
29+
cin>>b;
30+
cout<<"\nEnter the degree of accuracy desired"<<endl;
31+
cin>>e;
32+
if (f(a)*f(b)>0)
33+
{
34+
cout<<"Please enter a different initial guess"<<endl;
35+
goto a;
36+
}
37+
else
38+
{
39+
while (fabs(a-b)>=e)
40+
{
41+
c=(a+b)/2.0;
42+
fa=f(a);
43+
fb=f(b);
44+
fc=f(c);
45+
cout<<"a="<<a<<" "<<"b="<<b<<" "<<"c="<<c<<" fc="<<fc<<endl;
46+
if (fc==0)
47+
{
48+
cout<<"The root of the equation is "<<c;
49+
break;
50+
}
51+
52+
53+
if (fa*fc>0)
54+
{
55+
a=c;
56+
}
57+
else if (fa*fc<0)
58+
{
59+
b=c;
60+
}
61+
62+
63+
64+
65+
}
66+
}
67+
cout<<"The root of the equation is "<<c;
68+
return 0;
69+
}
70+

Numerical Method/lab1.cpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/************************************************************************/
2+
/* Name: Towfiqul Islam */
3+
/* uva id: 448714 */
4+
/* email id: towfiq.106@gmail.com */
5+
/* institute: IIUC */
6+
/* address: Chittagong, Bangladesh */
7+
/* */
8+
/************************************************************************/
9+
10+
/****
11+
12+
13+
Lab 1: Implementation of Bisection method
14+
Course name: Numerical Methods Sessional
15+
Course code: CSE-3608
16+
17+
Submitted to:
18+
Md. Sabir Hossain
19+
Dept. of CSE,
20+
CUET
21+
22+
23+
Submitted by:
24+
Towfiqul Islam
25+
ID: C141018
26+
Section: 6AM
27+
6th semester, Dept of CSE, IIUC
28+
Date of Submission: 07/11/16
29+
*******/
30+
31+
32+
/***
33+
34+
Implementation of Bisection method algorithm
35+
C++ code:
36+
37+
****/
38+
39+
40+
#include<bits/stdc++.h>
41+
#include<iostream>
42+
#include<cmath>
43+
#include<iomanip>
44+
using namespace std;
45+
double f(double x) //define the function here, ie give the equation
46+
{
47+
double a=pow(x,3)-x-11.0; //write the equation whose roots are to be determined
48+
return a;
49+
}
50+
int main()
51+
{
52+
cout.precision(4); //set the precision
53+
cout.setf(ios::fixed);
54+
double a,b,c,e,fa,fb,fc; //declare some needed variables
55+
a:cout<<"Enter the initial guesses:\na="; //Enter the value of a(set a label('a:') for later use with goto)
56+
cin>>a;
57+
cout<<"\nb="; //Enter the value of b
58+
cin>>b;
59+
cout<<"\nEnter the degree of accuracy desired"<<endl; //Enter the accuracy
60+
cin>>e; //e stands for accuracy
61+
if (f(a)*f(b)>0) //Check if a root exists between a and b
62+
{ //If f(a)*f(b)>0 then the root does not exist between a and b
63+
cout<<"Please enter a different intial guess"<<endl;
64+
goto a; //go back to 'a' ie 17 and ask for different values of a and b
65+
}
66+
else //else a root exists between a and b
67+
{
68+
while (fabs(a-b)>=e) /*if the mod of a-b is greater than the accuracy desired keep bisecting the interval*/
69+
{
70+
c=(a+b)/2.0; //bisect the interval and find the value of c
71+
fa=f(a);
72+
fb=f(b);
73+
fc=f(c);
74+
cout<<"a="<<a<<" "<<"b="<<b<<" "<<"c="<<c<<" fc="<<fc<<endl;
75+
/*print the values of a,b,c and fc after each iteration*/
76+
if (fc==0) //if f(c)=0, that means we have found the root of the equation
77+
{
78+
cout<<"The root of the equation is "<<c; /*print the root of the equation and break out of the loop*/
79+
break;
80+
}
81+
82+
if (fa*fc>0) //if f(a)xf(c)>0, that means no root exist between a and c
83+
{
84+
a=c; /*hence make a=c, ie make c the starting point of the interval and b the end point*/
85+
}
86+
else if (fa*fc<0)
87+
{
88+
b=c; /*this means that a root exist between a and c therfore make c the end point of the interval*/
89+
}
90+
91+
92+
}
93+
} /**The loop ends when the difference between a and b becomes less than the desired accuracy
94+
ie now the value stored in 'c' can be called the approximate root of the equation **/
95+
cout<<"The root of the equation is "<<c; //print the root
96+
return 0;
97+
}
98+
//output attached as jpg

0 commit comments

Comments
 (0)