ThinkTronix
learning is fun...
Home
Home
E-Books
Robotics
Coding
C++
Tutorials
Robotics
Softwares
Social Profiles
Popular
Tags
Blog Archives
Popular Posts
Volume of a Cube, Cuboid & Cylinder using Function Overloading
Write a Program to find Volume of a Cube, Cuboid & Cylinder using Function Overloading. #include<iostream> using namespace std...
Robotics: Using Atmega16 Microcontroller - Introduction
What is a Microcontroller? A microcontroller is a single chip, self-contained computer which incorporates all the basic components of...
NI Multisim 11.0
NI Multisim (formerly MultiSIM ) is an electronic schematic capture and simulation program which is part of a suite of circuit desi...
Area using Default Arguments
Write a Program to find Area of a Square & Rectangle using Default Arguments. #include<iostream> using namespace std; int sqr(...
Swap using Call by Address.
Write a Program to enter two no.s and swap their values using Call by Address. #include<iostream> using namespace std; void swap(i...
Tags
C++ code
electronics
free download
free ebooks
mediafire
programming
software
video
Blog Archive
▼
2012
(24)
►
May
(1)
►
April
(3)
►
February
(6)
▼
January
(14)
Volume of a Cube, Cuboid & Cylinder using Function...
Swap using Call by Address.
Swap using Call by Value
Swap using Call by Reference
Sum of Digits
Inline Function
Default Argument
Pattern -3
Pattern - 2
Pattern -1
Palindrome String
Palindrome Number
Matrix Multiplication
Matrix Addition
►
2011
(2)
►
December
(2)
Monday, January 30, 2012
Volume of a Cube, Cuboid & Cylinder using Function Overloading
8:35 PM
C++ code
,
Function Overloading
No comments
Write a Program to find Volume of a Cube, Cuboid & Cylinder using Function Overloading.
#include<iostream> using namespace std; int main() { int l=0,b=0,h=0,r=0,ch; cout<<"1.Volume of cube\n2.Volume of cuboid\n3.Volume of cylinder\nEnter choice: "; cin>>ch; switch(ch) { case 1:cout<<"Length= "; cin>>l; cout<<"Volume= "<<volume(l)<<endl; break; case 2:cout<<"Length= "; cin>>l; cout<<"Breadth= "; cin>>b; cout<<"Height= "; cin>>h; cout<<"Volume= "<<volume(l,b,h)<<endl; break; case 3:cout<<"Radius= "; cin>>r; cout<<"Height= "; cin>>h; cout<<"Volume= "<<volume(r,h)<<endl; break; default:cout<<"Wrong choice."; } return 0; } int volume(int a) { return a*a*a; } int volume(int a,int b,int c) { return a*b*c; } float volume(int a,int b) { return 3.142*a*a*b; }
Read More
Swap using Call by Address.
8:30 PM
C++ code
,
Call by address
,
swap numbers
No comments
Write a Program to enter two no.s and swap their values using Call by Address.
#include<iostream> using namespace std; void swap(int*,int*); int main() { int a,b; cout<<"Enter the no.s to be swapped: "; cin>>a>>b; swap(&a,&b); cout<<"The swapped values are: "<<a<<" & "<<b<<endl; return 0; } void swap(int *x,int *y) { *x=*x+*y; *y=*x-*y; *x=*x-*y; }
Read More
Swap using Call by Value
8:29 PM
C++ code
,
Call by value
,
swap numbers
No comments
Write a Program to enter two no.s and swap their values using Call by Value.
#include<iostream> using namespace std; int main() { int a,b; cout<<"Enter the no.s to be swapped: "; cin>>a>>b; swap(a,b); cout<<"The swapped values are: "<<a<<" & "<<b<<endl; return 0; } void swap(int x,int y) { x=x+y; y=x-y; x=x-y; }
Read More
Swap using Call by Reference
8:28 PM
C++ code
,
Call by Reference
,
swap numbers
No comments
Write a Program to enter two no.s and swap their values using Call by Reference
#include<iostream> using namespace std; int main() { int a,b; cout<<"Enter the no.s to be swapped: "; cin>>a>>b; swap(a,b); cout<<"The swapped values are: "<<a<<" & "<<b<<endl; return 0; } void swap(int &x,int &y) { x=x+y; y=x-y; x=x-y; }
Read More
Sum of Digits
8:22 PM
C++ code
,
Sum of Digits
No comments
Write a Program to enter a no. & find the sum of its digits.
#include<iostream> using namespace std; int main() { int num,rem=0,sum=0,n; cout<<"Enter the no.:"; cin>>num; n=num; while(n>0) { rem=n%10; sum+=rem; n/=10; } cout<<"The sum of digits of "<<num<<" = "<<sum<<"\n"; return 0; }
Read More
Inline Function
8:20 PM
C++ code
,
Inline Function
,
Simple Interest
No comments
Write a Program to calculate Simple Interest & show the use of Inline function.
#include<iostream> using namespace std; float sim_int(int,int,int); int main() { int prin,time,rate; cout<<"Enter the principal: "; cin>>prin; cout<<"Enter the time in years: "; cin>>time; cout<<"Enter the rate: "; cin>>rate; cout<<"Simple Interest= "<<sim_int(prin,time,rate)<<endl; return 0; } inline float sim_int(int p,int t,int r) { return (p*t*r)/100; }
Read More
Default Argument
8:17 PM
C++ code
,
Default Argument
No comments
Write a Program to enter two no.s, m & n and find m^n using default arguments such that the output is square of m. Do not use Library functions.
#include<iostream> using namespace std; int pow(int a=1,int b=2); int main() { int m,n; cout<<"Enter the no.: "; cin>>m; cout<<"Enter the power : "; cin>>n; cout<<"Result= "<<pow(m,n); cout<<"\nDefault Result= "<<pow(m)<<endl; return 0; } int pow(int a,int b) { int t=a; for(int i=1;i<=b;i++)t=t*t; return t; }
Read More
Pattern -3
8:11 PM
C++ code
,
pattern
No comments
Write a Program to enter the no. of rows & print the following Pattern:
*
* *
* * *
* * * *
* * * * *
#include<iostream> using namespace std; int main() { int spc,star,r,i,j; cout<<"Enter the no. of rows: "; cin>>r; star=1; spc=r-1; for(i=0;i<r;i++) { for(j=0;j<spc;j++) cout<<" "; for(j=0;j<star;j++) cout<<"*"; spc--; star++; cout<<endl; } return 0; }
Read More
Pattern - 2
8:05 PM
C++ code
,
pattern
No comments
Write a Program to enter the no. of rows & print the following Pattern:
+
+ + +
+ + + + +
+ + + + + + +
#include<iostream> using namespace std; int main() { int sp,plus,r,i,j; cout<<"Enter the no. of rows: "; cin>>r; plus=1; sp=r-1; for(i=0;i<r;i++) { for(j=0;j<sp;j++)cout<<" "; for(j=0;j<plus;j++)cout<<"+"; plus+=2; sp--; cout<<endl; } return 0; }
Read More
Wednesday, January 25, 2012
Pattern -1
10:21 PM
C++ code
,
pattern
No comments
Write a Program to enter a starting number(x) and print the number the following Pattern :
for x=5
5
54
543
5432
54321
#include<iostream> using namespace std; int main() { int i,j,k,x; cout<<"Enter the starting no:"; cin>>x; for(i=1;i<=x;i++) { k=x; for(j=0;j<i;j++) { cout<<k<<" "; k--; } cout<<"\n"; } return 0; }
Read More
Palindrome String
10:12 PM
C++ code
,
palindrome
No comments
Write a Program to input a String and check whether it is a Palindrome or not.
#include<iostream> using namespace std; int main() { char str[20],rev[20]; int i,j,k=0,flag=0; cout<<"Enter the string:"; cin>>str; for(i=0;str[i]!='\0';i++); for(j=i;j>0;j--) { rev[j-1]=str[k]; k++; } cout<<"The reverse="<<rev<<"\n"; for(j=0;str[j]!='\0';j++) if(str[j]!=rev[j]) { flag=1; break; } if(flag==0)cout<<"Palindrome\n"; else cout<<"Not Palindrome\n"; return 0; }
Read More
Palindrome Number
10:10 PM
C++ code
,
palindrome
No comments
Write a Program to input a number and check whether it is a Palindrome or not.
#include<iostream> using namespace std; int main() { int num,rev=0,rem=0,n; cout<<"Enter the number:"; cin>>num; n=num; while(n>0) { rem=n%10; rev=rev*10+rem; n/=10; } cout<<"The reverse of "<<num<<" = "<<rev<<"\n"; if(num==rev)cout<<num<<" is a palindrome\n"; else cout<<num<<" is not a palindrome\n"; return 0; }
Read More
Matrix Multiplication
10:01 PM
C++ code
,
matrix multiplication
No comments
Write a Program to enter two matrices and print their Product.
#include<iostream> using namespace std; int main() { int a[5][5],b[5][5],c[7][7],i,j,k,r1,c1,r2,c2; cout<<"Enter the order of first matrix:"; cin>>r1>>c1; cout<<"Enter the order of second matrix:"; cin>>r2>>c2; if(c1!=r2) { cout<<"Multiplication not possible.\n"; return 0; } cout<<"Enter the first matrix:\n"; for(i=0;i<r1;i++) for(j=0;j<c1;j++) cin>>a[i][j]; cout<<"Enter the second matrix:\n"; for(i=0;i<r2;i++) for(j=0;j<c2;j++) cin>>b[i][j]; for(i=0;i<r1;i++) for(j=0;j<c2;j++) c[i][j]=0; for(i=0;i<r1;i++) for(j=0;j<c2;j++) for(k=0;k<c1;k++) c[i][j]+=a[i][k]*b[k][j]; cout<<"The product matrix is:\n"; for(i=0;i<r1;i++) { for(j=0;j<c2;j++) cout<<c[i][j]<<" "; cout<<"\n"; } return 0; }
Read More
Matrix Addition
9:28 PM
C++ code
,
sum of matrices
No comments
Write a program to enter two matrices and print their sum.
#include<iostream> using namespace std; int main() { int a[5][5],b[5][5],s[5][5]; int r=0,c=0,i=0,j=0; cout<<"Enter the no. of rows:"; cin>>r; cout<<"Enter the no. of columns:"; cin>>c; cout<<"Enter values into first array:"; for(i=0;i<r;i++) for(j=0;j<c;j++) cin>>a[i][j]; cout<<"Enter values into second array:"; for(i=0;i<r;i++) for(j=0;j<c;j++) cin>>b[i][j]; for(i=0;i<r;i++) for(j=0;j<c;j++) s[i][j]=a[i][j]+b[i][j]; cout<<"The matrix sum:"; for(i=0;i<r;i++) { cout<<"\n"; for(j=0;j<c;j++) cout<<s[i][j]<<" "; } cout<<"\n"; return 0; }
Read More
Newer Posts
Older Posts
Home