Category Archives: C++

Function Overloading using C++

/*/* * inlines.cpp * *  Created on: Jul 16, 2017 *      Author: asharda */ #include<iostream>using namespace std;inline int mul(int x,int y=10){ return x*y;} double mul(double x,double y){ return x*y;} int main(){ cout<<mul(5)<<“\n”; cout<<“Mul using Double”<<mul(5.50,10.0);} Advertisements

Posted in C++, Uncategorized | Leave a comment

Using Friend Function C++

/*/* * sample.cpp * *  Created on: Jul 9, 2017 *      Author: asharda */ #include<iostream>using namespace std; class sample{public: int a; int b; friend float mean(sample s); }; float mean(sample s){ return float  (s.a+s.b)/2.0;} int main(){ sample s; s.a=10; s.b=20; cout<<“Value seen is “<<mean(s); … Continue reading

Posted in C++, Uncategorized | Leave a comment

Bubble Sort C++

/* *bubblesort.cpp * * Created on: May 28, 2017 * Author: asharda */ #include<iostream> using namespace std; void bubblesort(int arr[],int size) { int temp; for (int i=0;i<size;i++) { for (int j=i+1;j<size;j++) { if(arr[i] >arr[j]) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; }//end of … Continue reading

Posted in C++, Data Structures, Uncategorized | Leave a comment

Functions and Arrays in C++

/* * arraysis.cpp * * Created on: May 28, 2017 * Author: asharda */ #include<iostream> using namespace std; void printarr(int arr[],int size) { for (int i=0;i<size;i++) { cout<<arr[i]<<“\n”; } } int main() { int arr[]={1,2,3,4,5}; printarr(arr,5); }

Posted in C++, Uncategorized | Leave a comment

Basic String Functions C++

/* * stringfunctions.cpp * * Created on: May 02, 2017 * Author: asharda */ #include<iostream> #include<cstring> using namespace std; int main() { char str1[10]=”Hello”; char str2[10]=”C++”; char str3[10]; //Copy Str1 in Str3 strcpy(str3,str1); cout<<str3<<“\n”; //Concatenate Str2 to Sr3 strcat(str3,str2); cout<<“Concatenated … Continue reading

Posted in C++ | Leave a comment

Print Hello C++

#include<iostream> using namespace std; int main() { char greeting[]={‘H’,’e’,’l’,’l’,’o’,’\0′}; cout<<greeting; }

Posted in C++, Uncategorized | Leave a comment

Find the area of the Rectangle -C++

/* * Rectangle.cpp * * Created on: Jan 29, 2017 * Author: asharda */ #include <iostream> using namespace std; class Rectangle { int width,height; public : void set_values(int ,int); int area(); }; /** * Set the values of the Rectangle … Continue reading

Posted in C++ | Leave a comment