diff --git a/Add-nums-with-bitwise.cpp b/Add-nums-with-bitwise.cpp new file mode 100644 index 0000000..3abd4fb --- /dev/null +++ b/Add-nums-with-bitwise.cpp @@ -0,0 +1,27 @@ +#include +int main() +{ + int number,number2,sum,carry; + + do{ + printf("Enter 1st Number: "); + scanf("%d",&number); + + printf("Enter 2nd Number: "); + scanf("%d",&number2); + + + while(number2!=0){ + sum= number ^ number2; + carry= (number & number2)<<1; + number=sum; + number2=carry; + } + + printf("Addition is: %d\n",number); + + + }while(true); + return 0; + +} diff --git a/matrix calculator.cpp b/matrix calculator.cpp new file mode 100644 index 0000000..a6a8139 --- /dev/null +++ b/matrix calculator.cpp @@ -0,0 +1,128 @@ +#include +#include +using namespace std; + +void setmatrix(int array[3][3]) + { + cout<<"Enter Values:\n"; + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + cout<<"("<>array[i][j]; + } + } + } + +void showmatrix(int array[3][3]) + { + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + {cout<>c; + switch(c) + { + case '*': + matrixmultiplication(A,B); + break; + + case '+': + matrixaddition(A,B); + break; + + case '-': + matrixsubtraction(A,B); + break; + + case '/': + matrixdivision(A,B); + break; + + default: + cout<<"Invalid operator!!!"; + + } + cout<<"\nDo u want to perform another operation again(y/n)? :"; + cin>>doagain; + } + + +} diff --git a/pointers.cpp b/pointers.cpp new file mode 100644 index 0000000..32ce12f --- /dev/null +++ b/pointers.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; +int main() +{ int h=5; +char c='Z'; + int* v; + v=&h; + char *b; + b=&c; + //b=&h; //error1= cannot convert 'int*' to 'char*' in assignment + cout<<"h= "< +#include +using namespace std; +int main() +{ + ifstream reading("C:/Users/zohaib hassan/Desktop/tuesday/filing/zhs.txt"); + char data[200]; + while(!reading.eof()) //or while(reading + { + reading.getline(data,200); + cout<>word) + { + if(word=="stored") + { + cout< +using namespace std; +int main() +{ int a; +cout<<"enter any integer ="; +cin>>a; + switch(a) + { case 60: + case 50: +// if cases r not identified in input then default will be executed. + case 40: + cout<<"A grade"; + break; + case 30: + case 20: + cout<<"D grade."; + break; + default: + cout<<"Any other grade than \"A\" or \"D\""; + } + + + } diff --git a/time conversion.cpp b/time conversion.cpp new file mode 100644 index 0000000..ef88c94 --- /dev/null +++ b/time conversion.cpp @@ -0,0 +1,14 @@ +#include +#include +using namespace std; +int main() +{ int hours,secs,mins; +cout<<"Enter no of hours= "; +cin>>hours; +mins=hours*60; +cout<<"Mins in given hours= "<