Technical Akash
Wednesday, January 4, 2023
Saturday, November 9, 2019
Python Basic
1. Hello world program in Python IDLE:-
print("hello world");
sentence="there is a boy";
print(sentence);
print(sentence.replace("boy","girl"));
print(sentence);
print(sentence[1:4]);
print(sentence.upper())
print(sentence.lower())
2. Loop in python :-
n=0
print("this is a program to find sum of first 100 numbers")
for i in range(5):
i=i+1
n=n+i
print('the sum is ' + str(n))
4.Example program:-
print('what is your name?')
name=input()
print('hello ' + name)
x=len(name)
print('number of characters in your name is:' + str(len(name)))
print("enter a number")
num1=input()
print('you entered '+num1)
5. Example 4
# Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
# Add two numbers
sum = float(num1) + float(num2)
# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
Tuesday, March 26, 2019
C++ with technical akash | Object Oriented Programming
OBJECT ORIENTED PROGRAMMING USING C++
passing object as a fun argument
#include<iostream>using namespace std;
class time
{
int hour;
int minute;
public:
void gettime(int h,int m)
{
hour=h;
minute=m;
}
void puttime()
{
cout<<hour<<"hours";
cout<<minute<<"minutes";
}
void sum(time,time);
};
void time:: sum(time t1,time t2)
{
minute=t1.minute+t2.minute;
hour=minute/60;
minute=minute%60;
hour=hour+t1.hour+t2.hour;
}
int main()
{
time T1,T2,T3;
T1.gettime(2,45);
T2.gettime(3,30);
T3.sum(T1,T2);
cout<<endl<<"M = ";
T1.puttime();
cout<<endl<<"N = ";
T2.puttime();
cout<<endl<<"P = ";
T3.puttime();
return 0;
}
Friend function
#include<iostream>using namespace std;
class sample
{
int a;
int b;
public:
void setvalue()
{
a=25;
b=40;
}
friend float mean(sample s); //here s object is decleared
};
float mean(sample s)
{
return float(s.a+s.b)/2.0;
}
int main()
{
sample x;
x.setvalue(); //here private data is accessed through member function setvalue
cout<<"mean value=" <<mean(x) <<endl;
return 0;
}
#include<iostream>
using namespace std;
class A; //forward declearation
class B
{
int a;
public:
void setdata (int x)
{
a=x;
}
friend void fun(A,B);
};
class A
{
int b;
public:
void setdata(int y)
{
b=y;
}
friend void fun(A,B);
};
void fun(A o1,B o2)
{
cout<<"sum="<<o1.b+o2.a;
}
int main()
{
A obj1;
B obj2;
obj1.setdata(2);
obj2.setdata(3);
fun(obj1,obj2);
return 0;
}
Static Data Member Function :-
#include<iostream>
using namespace std;
class A
{
static int count;
int num;
public:
void getdata(int a1)
{
num=a1;
count ++;
}
void getcount ()
{
cout<<"count:"<<count<<endl;
}
};
int A:: count; //definition of static data
int main()
{
A a,b,c;
a.getcount();
b.getcount();
c.getcount();
a.getdata(100);
b.getdata(200);
c.getdata(300);
cout<<"after calling " <<endl;
a.getcount();
b.getcount();
c.getcount();
return 0;
}
Constructor :-
#include<iostream>
using namespace std;
class a
{
int m,n;
public:
a() //constructor
{
m=1;
n=2;
}
void display()
{
cout<<"m="<<m<<endl;
cout<<"n="<<n<<endl;
}
};
int main()
{
a o; //object o is created of class a and constructor is called automatically
o.display();
return 0;
}
#include<iostream>
using namespace std;
class gce
{
int m,n;
public:
gce(int x, int y); //decleration of constructor
void display()
{
cout<<m<<n<<endl;
}
gce()
{
}
};
gce :: gce(int x=1,int y=2) //definition of constructor outside class first gce is class name and other is function name
{
m=x;
n=y;
}
int main()
{
//gce g;
gce g=gce(10,20);
//gce g(10,20);
g.display();
return 0;
}
Tuesday, February 26, 2019
Node MCU & Arduino : Microcontroller for IoT devices
Node MCU (ESP8266) is a microcontroller having similar function as Arduino which has many advantages over Arduino UNO i.e. Low cost,integrated support for wifi networks, small , low power consumption.
best websites for better understanding :
Official website - click here
Arduino uno offical website for software installation - click here
https://www.elecrow.com -click here
Arduino code for led blinking - click here
nodeMCU code:-
wifi server - click here
IIT BHU Robotics workshop files - click here
IIT Patna workshop files - click here
Arduino code for led blinking - click here
nodeMCU code:-
wifi server - click here
IIT BHU Robotics workshop files - click here
IIT Patna workshop files - click here
Online Shopping
Tuesday, February 5, 2019
C++ Programming with Technical Akash | Conditionals and Loops
To print table of any number ; input of the number is taken by the user ; using for loop
#include<iostream>
using namespace std;
int main()
{
float i;
int x;
cout <<"table of any number" <<endl <<"enter the number whose table is to be write" <<endl ;
cin>> i;
for(x=1;x<11;x++)
{
cout <<x <<"x" <<i <<"=" <<x*i << endl ;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
float i;
int x;
cout <<"table of any number" <<endl <<"enter the number whose table is to be write" <<endl ;
cin>> i;
for(x=1;x<11;x++)
{
cout <<x <<"x" <<i <<"=" <<x*i << endl ;
}
return 0;
}
while loop
#include<iostream>
using namespace std;
int main()
{
int i=1,j;
cout <<"enter the last number" <<endl ;
cin>>j;
cout <<"this is our counting from 1" << endl;
while(i<=j)
{
cout<<i <<endl;
i++;
}
}
do while loop
#include<iostream>
using namespace std;
int main()
{
int a,b;
cout << "enter the first and last number " <<endl;
cin>>a;
cin>>b;
int c =a;
cout<<"the series is " <<endl;
do
{
cout<< c <<endl;
c+=2;
}
while (c<=b);
}
#include<iostream>
using namespace std;
int main()
{
int a,b;
cout << "enter the first and last number " <<endl;
cin>>a;
cin>>b;
int c =a;
cout<<"the series is " <<endl;
do
{
cout<< c <<endl;
c+=2;
}
while (c<=b);
}
output
C++ with Technical Akash | Function
* A function is a group of statements that can perform a particular tasks.
But how we was performing the tasks without knowing about function ? Actually we was using a function named "main" function . A c++ program must have at least one function.
We can reuse function and we can modify it somewhere in program.
#include<iostream>
using namespace std;
int akash()
{
cout<< "technical akash will solve your all problems";
}
int main()
{
akash();
}
But how we was performing the tasks without knowing about function ? Actually we was using a function named "main" function . A c++ program must have at least one function.
We can reuse function and we can modify it somewhere in program.
#include<iostream>
using namespace std;
int akash()
{
cout<< "technical akash will solve your all problems";
}
int main()
{
akash();
}
Here int is called function return type which must be defined , and akash is function name which is further recalled in int function.
=> we can also modify functon after defining it , see below a example :-
#include<iostream>
using namespace std;
int akash()
int main()
{
akash();
akash();
}
int akash()
{
cout<< "technical akash will solve your all problems"<<endl;
cout << "this is our modified function "<<endl;
}
Subscribe to:
Posts (Atom)