├── .github └── FUNDING.yml ├── .gitignore ├── C ├── 2DMatrix.c ├── Armstrong.c ├── Factors.c ├── fibonacci.c ├── filesWithString.c ├── first.c ├── help.txt ├── lineReverse.c ├── maximumofarray.c ├── maxofarray.c ├── numberReverse.c ├── operators.c ├── palindrome.c ├── primeNumber.c ├── programAsFuntions.c ├── reverse.c ├── rupee.c ├── rupee2.c ├── sizeoffile.c ├── stringReverse.c ├── swaptwovalue.c └── triangle.c ├── CPP ├── 00-Basics │ ├── basics.cpp │ └── dub.cpp ├── 01-Recursion │ ├── factorial.cpp │ └── recursion.cpp ├── 02-OOPs │ └── class.cpp ├── 03-FileHandling │ ├── demo.txt │ ├── file.cpp │ ├── fileOps.cpp │ └── readfile.cpp ├── 04-Operators │ └── ternary.cpp ├── 05-Polymorphism │ ├── Polymorphism.txt │ ├── functionOverriding.cpp │ ├── functionoverloading.cpp │ ├── operatoroverloading.cpp │ └── virtualFunctions.cpp └── accessSpecifier.cpp └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: ['https://paytm.me/YyD-Wkw'] 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | .vscode 34 | Rupees.c 35 | rupeeprint.c 36 | -------------------------------------------------------------------------------- /C/2DMatrix.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int a[3][3],b[3][3],c[3][3]; 5 | int i,j,m; 6 | for(i=0;i<3;i++){ 7 | printf("\nEnter the value of row: "); 8 | scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]); 9 | } 10 | for(i=0;i<3;i++){ 11 | printf("\nEnter the value of row: "); 12 | scanf("%d %d %d",&b[i][0],&b[i][1],&b[i][2]); 13 | } 14 | 15 | //matrix a and b printing 16 | printf("Matrix A: \n"); 17 | for(i=0;i<3;i++){ 18 | for(j=0;j<3;j++){ 19 | printf("%d ",a[i][j]); 20 | } 21 | printf("\n"); 22 | } 23 | printf("Matrix B: \n"); 24 | for(i=0;i<3;i++){ 25 | for(j=0;j<3;j++){ 26 | printf("%d ",b[i][j]); 27 | } 28 | printf("\n"); 29 | } 30 | printf("\nMultiplication of given matirix is : \n"); 31 | for(i=0;i<3;i++){ 32 | for(j=0;j<3;j++){ 33 | c[i][j]=0; 34 | for(m=0;m<3;m++){ 35 | c[i][j]+=(a[i][m]*b[m][j]); 36 | } 37 | } 38 | } 39 | 40 | //printing the result Matirx C 41 | for(i=0;i<3;i++){ 42 | for(j=0;j<3;j++){ 43 | printf("%d ",c[i][j]); 44 | } 45 | printf("\n"); 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /C/Armstrong.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int armstrong(int n){ 4 | 5 | int sum=0; 6 | int remain; 7 | int x = n; 8 | 9 | while( x > 0){ 10 | remain = x % 10; 11 | sum = sum + remain*remain*remain; 12 | x /= 10; 13 | } 14 | if ( n == sum){ 15 | printf("\n%d is a Armstrong number!",n); 16 | } else { 17 | printf("\n%d is not a Armstrong number!",n); 18 | } 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C/Factors.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int factors(int n){ 4 | int x=2; 5 | int flag=0; 6 | 7 | printf("\nFactors of given Number %d: ",n); 8 | while(x<=n/2){ 9 | if(n%x==0){ 10 | printf("%d",x); 11 | printf(","); 12 | flag = 1; 13 | } 14 | x++; 15 | } 16 | if (flag==0){ 17 | printf("No factors other than 1 and %d",n); 18 | } 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C/fibonacci.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int n; 5 | int first=0,second=1; 6 | int next,i=1; 7 | printf("enter how much fabonacci series you want to print: "); 8 | scanf("%d",&n); 9 | printf("%d ",first); 10 | while(i 3 | #include 4 | 5 | int main(){ 6 | char line[1000]; 7 | int i=0; 8 | char ch; 9 | char word[15]; 10 | char rline[1000]; 11 | int count=0; 12 | 13 | FILE *fpointer; 14 | fpointer = (fopen("help.txt", "r+")); 15 | printf("content of the file before the reversing: \n"); 16 | while(1){ 17 | ch = fgetc(fpointer); //READING CHARACTER FROM FILE 18 | line[i]=ch; 19 | i++; 20 | 21 | if (ch == EOF){ 22 | break; 23 | } 24 | printf("%c",ch); 25 | } 26 | count=0; 27 | while(line[count]!=EOF){ 28 | count++; 29 | } 30 | 31 | line[count]='\0'; 32 | i = 0; 33 | int w,w1=0,last; 34 | int len=count-1; 35 | int space=0; 36 | printf("length of string is : %d\n",count); 37 | while(i<=count){ 38 | if((line[i]==' ') || (line[i]=='\0')||(line[i]=='\n')){ 39 | last = i-1; 40 | for(w=w1;w //header file library 2 | 3 | int main(){ //main functions (everything in main() will be executed) 4 | printf("Hii C ! Long time !"); 5 | 6 | return 0; //return 0 endthe main function 7 | } -------------------------------------------------------------------------------- /C/help.txt: -------------------------------------------------------------------------------- 1 | sihT si a ymmud .elif 2 | I ma gnikrow no a gnirts esrever .ksat 3 | yM margorp si .gnikrow 4 | woN I tnaw ot yrt emos elif gnildnah htiw .ti 5 | s'tel og -------------------------------------------------------------------------------- /C/lineReverse.c: -------------------------------------------------------------------------------- 1 | // reverse a given line by user 2 | #include 3 | #include 4 | 5 | int main(){ 6 | char line[100]; 7 | int i=0; 8 | char word[15]; 9 | char rline[100]; 10 | int count=0; 11 | printf("Enter a line to reverse: "); 12 | gets(line); 13 | while(line[count]!='\0'){ 14 | count++; 15 | } 16 | 17 | line[count]='\0'; 18 | i = 0; 19 | int w,w1=0,last; 20 | int len=count-1; 21 | printf("You enter this line: %s\n",line); 22 | printf("length of string is: %d\n",count); 23 | while(i<=count){ 24 | if((line[i]==' ') || (line[i]=='\0')){ 25 | last = i-1; 26 | for(w=w1;w 2 | 3 | int main(){ 4 | int n[10]={1,52,4,21,25,17,8,9,15,24}; 5 | int bigger=0; 6 | int i=0,x; 7 | while(i<10){ 8 | bigger=(n[i]>bigger)?n[i]:bigger; 9 | i++; 10 | } 11 | 12 | printf("biggest number of arry is : %d",bigger); 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /C/maxofarray.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int n[10]={1,52,4,21,25,17,8,9,61,24}; 5 | int bigger=0; 6 | int i=0,x; 7 | while(i<10){ 8 | bigger=(n[i]>bigger)?n[i]:bigger; 9 | i++; 10 | } 11 | 12 | printf("biggest number of arry is : %d",bigger); 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /C/numberReverse.c: -------------------------------------------------------------------------------- 1 | // reverse the given number 2 | #include 3 | 4 | int numberReverse(int n){ 5 | 6 | int sum=0; 7 | int remain; 8 | 9 | // printf("Enter a number to reverse: "); 10 | // scanf("%d",&n); 11 | 12 | while(n>0){ 13 | remain = n%10; 14 | sum =sum*10+remain; 15 | n/=10; 16 | } 17 | printf("\nreverse of given number is %d",sum); 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /C/operators.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int x=5; 5 | printf("Enter Something: "); 6 | scanf("%d",&x); 7 | x|=13; 8 | printf("%d",x); 9 | 10 | 11 | return 0; 12 | } -------------------------------------------------------------------------------- /C/palindrome.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int palindrome(int n){ 4 | 5 | int sum=0; 6 | int remain; 7 | int x = n; 8 | while(x>0){ 9 | remain = x%10; 10 | sum =sum*10+remain; 11 | x/=10; 12 | } 13 | if (n==sum){ 14 | printf("%d is a paindrome number!\n",n); 15 | } else { 16 | printf("%d is not a palindrome number!\n",n); 17 | } 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /C/primeNumber.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int primenumber(int n){ 4 | int i; 5 | bool flag =true; 6 | // printf("Enter a number to check its prime or not: "); 7 | // scanf("%d",&n); 8 | for (i=2;i<=n/2;i++){ 9 | if(n%i==0){ 10 | printf("%d is Not a prime number;",n); 11 | flag = false; 12 | break; 13 | }; 14 | } 15 | if (flag){ 16 | printf("%d is a Prime number!",n); 17 | } 18 | 19 | 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /C/programAsFuntions.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "palindrome.c" 3 | #include "primeNumber.c" 4 | #include "numberReverse.c" 5 | #include "armstrong.c" 6 | #include "factors.c" 7 | int palindrome(int n); 8 | int primenumber(int n); 9 | int numberReverse(int n); 10 | int armstrong(int n); 11 | int factors(int n); 12 | int main(){ 13 | int num; 14 | int result; 15 | int input=0; 16 | 17 | printf("Enter a number: "); 18 | scanf("%d",&num); 19 | // calling the functions 20 | palindrome(num); 21 | primenumber(num); 22 | numberReverse(num); 23 | factors(num); 24 | armstrong(num); 25 | 26 | // switch(input){ 27 | // case 1: 28 | // printf("Enter a number two check its palindrome or not: "); 29 | // scanf("%d",&num); 30 | // palindrome(num); 31 | // break; 32 | // case 2: 33 | 34 | // break; 35 | // default: 36 | // printf("\nPlease enter a Valid Input!"); 37 | // } 38 | return 0; 39 | } -------------------------------------------------------------------------------- /C/reverse.c: -------------------------------------------------------------------------------- 1 | // reverse the given string 2 | #include 3 | #include 4 | 5 | int main(){ 6 | char name[20],rname[20]; 7 | int i,last; 8 | int length=0; 9 | 10 | printf("Enter name you want to reverse: "); //taking input from user 11 | gets(name); 12 | 13 | while(name[length]!='\0'){ // counting the length of array 14 | length+=1; 15 | } 16 | last = length-1; //index of last element in array 17 | for(i=0;i 2 | #include 3 | #include 4 | void unit(int x); 5 | void tenth(int x,int len,int* length,int *step); 6 | int main(){ 7 | char amount[10],iamount[10]; 8 | int i=0; 9 | int len=0; 10 | printf("Enter amount you want to convert: "); 11 | gets(amount); 12 | while(amount[i]!='\0'){ 13 | len++; 14 | i++; 15 | } 16 | amount[i]='\0'; 17 | len = len-1; 18 | int step =0; 19 | 20 | while (len>=0) 21 | { 22 | 23 | if((len==0)||(len==2)||(len==3)||(len==5)||(len==7)||(len==9)){ 24 | // printf("length is: %d\n",len); 25 | if(amount[step]=='0'){ 26 | len-=1; 27 | step+=1; 28 | continue; 29 | } 30 | if(amount[step]=='1'){ 31 | printf("One"); 32 | }else if(amount[step]=='2'){ 33 | printf("Two"); 34 | }else if(amount[step]=='3'){ 35 | printf("Three"); 36 | }else if(amount[step]=='4'){ 37 | printf("Four"); 38 | }else if(amount[step]=='5'){ 39 | printf(" Five "); 40 | }else if(amount[step]=='6'){ 41 | printf(" Six "); 42 | }else if(amount[step]=='7'){ 43 | printf(" Seven "); 44 | }else if(amount[step]=='8'){ 45 | printf(" Eight "); 46 | }else if (amount[step]=='9'){ 47 | printf(" Nine "); 48 | } 49 | unit(len); 50 | len-=1; 51 | step+=1; 52 | printf("\nstep inside first if : %d\n",step); 53 | 54 | }else if ((len==1)||(len==4)||(len==6)||(len==8)) 55 | { 56 | char check[2]; 57 | check[0]=amount[step]; 58 | check[1]=amount[step+1]; 59 | check[2]='\0'; 60 | // printf("check[2] is: %s\n",check); 61 | int ten = atoi(check); 62 | printf("step inside second if: %d\n",step); 63 | tenth(ten,len,&len,&step); 64 | } 65 | } 66 | printf(" Rupees Only\n"); 67 | return 0; 68 | } 69 | 70 | void unit(int x){ 71 | if((x==2)){ 72 | printf(" Hundred "); 73 | } 74 | else if((x==3)||(x==4)){ 75 | printf(" Thousand "); 76 | } 77 | else if((x==5)||(x==6)){ 78 | printf(" Lakh "); 79 | } 80 | else if((x==7)||(x==8)){ 81 | printf(" Crore "); 82 | }else if(x==9){ 83 | printf(" Arab "); 84 | } 85 | }; 86 | 87 | void tenth(int x,int len,int *length,int *step){ 88 | // printf("x is: %d\nlength is: %d\nstep is: %d\n",x,*length,*step); 89 | // printf("x is %d",x); 90 | if ((x<10)){ 91 | printf("length before tenth :%d\n",*length); 92 | printf("step before tenth : %d\n",*step); 93 | *length-=1; 94 | *step+=1; 95 | printf("after tenth\nstep: %d,\n length: %d\n",*step,*length); 96 | } 97 | else if ((x>9)&&(x<20)){ 98 | if(x==10){ 99 | printf(" Ten "); 100 | }else if(x==11){ 101 | printf(" Eleven "); 102 | }else if(x==12){ 103 | printf(" Twelve "); 104 | }else if(x==13){ 105 | printf(" Thirteen "); 106 | }else if(x==14){ 107 | printf(" Fourteen "); 108 | }else if(x==15){ 109 | printf(" Fifteen "); 110 | }else if(x==16){ 111 | printf(" Sixteen "); 112 | }else if(x==17){ 113 | printf(" Seventeen "); 114 | }else if(x==18){ 115 | printf(" Eighteen "); 116 | }else if(x==19){ 117 | printf(" Nineteen "); 118 | } 119 | unit(len); 120 | *length -=2; 121 | *step+=2; 122 | } 123 | else if ((x==20)||(x==30)||(x==40)||(x==50)||(x==60)||(x==70)||(x==80)||(x==90)){ 124 | if(x==20){ 125 | printf("Twenty "); 126 | }else if(x==30){ 127 | printf("Thirty "); 128 | }else if(x==40){ 129 | printf("Fourty "); 130 | }else if(x==50){ 131 | printf("Fifty "); 132 | }else if(x==60){ 133 | printf("Sixty "); 134 | }else if(x==70){ 135 | printf("Seventy "); 136 | }else if(x==80){ 137 | printf("Eightty "); 138 | }else if(x==90){ 139 | printf("Ninety "); 140 | } 141 | unit(len); 142 | *length =*length-2; 143 | *step+=2; 144 | } 145 | else{ 146 | if((x>20)||(x<100)){ 147 | if ((x>20)&&(x<30)){ 148 | printf(" Twenty "); 149 | 150 | } 151 | else if ((x>30)&&(x<40)){ 152 | printf(" Thirty "); 153 | } 154 | else if ((x>40)&&(x<50)){ 155 | printf(" Forty "); 156 | } 157 | else if ((x>50)&&(x<60)){ 158 | printf(" Fifty "); 159 | } 160 | else if ((x>60)&&(x<70)){ 161 | printf(" Sixty "); 162 | } 163 | else if ((x>70)&&(x<80)){ 164 | printf(" Seventy "); 165 | } 166 | else if ((x>80)&&(x<90)){ 167 | printf(" Eighty "); 168 | } 169 | else if ((x>90)&&(x<100)){ 170 | printf(" Ninety "); 171 | } 172 | *length-=1; 173 | *step+=1; 174 | } 175 | } 176 | }; -------------------------------------------------------------------------------- /C/rupee2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | void unit(int x); 5 | void tenth(int x,int len,int* length,int *step); 6 | void once(int x,int* length ,int* step,char amount[]); 7 | void twice(int* length, int* step ,char amount[]); 8 | int main(){ 9 | char amount[10],iamount[10]; 10 | int i=0; 11 | int len=0; 12 | printf("Enter amount you want to convert: "); 13 | gets(amount); 14 | while(amount[i]!='\0'){ 15 | len++; 16 | i++; 17 | } 18 | amount[i]='\0'; 19 | len = len-1; 20 | int step =0; 21 | 22 | while (len>=0) 23 | { 24 | once(len,&len,&step,amount); 25 | twice(&len,&step,amount); 26 | } 27 | printf("Rupees Only\n"); 28 | return 0; 29 | } 30 | 31 | void unit(int x){ 32 | if((x==2)){ 33 | printf("Hundred "); 34 | } 35 | else if((x==3)||(x==4)){ 36 | printf("Thousand "); 37 | } 38 | else if((x==5)||(x==6)){ 39 | printf("Lakh "); 40 | } 41 | else if((x==7)||(x==8)){ 42 | printf("Crore "); 43 | }else if(x==9){ 44 | printf("Arab "); 45 | } 46 | }; 47 | 48 | void tenth(int x,int len,int *length,int *step){ 49 | if ((x<10)){ 50 | *length-=1; 51 | *step+=1; 52 | } 53 | else if ((x>9)&&(x<20)){ 54 | if(x==10){ 55 | printf("Ten "); 56 | }else if(x==11){ 57 | printf("Eleven "); 58 | }else if(x==12){ 59 | printf("Twelve "); 60 | }else if(x==13){ 61 | printf("Thirteen "); 62 | }else if(x==14){ 63 | printf("Fourteen "); 64 | }else if(x==15){ 65 | printf("Fifteen "); 66 | }else if(x==16){ 67 | printf("Sixteen "); 68 | }else if(x==17){ 69 | printf("Seventeen "); 70 | }else if(x==18){ 71 | printf("Eighteen "); 72 | }else if(x==19){ 73 | printf("Nineteen "); 74 | } 75 | unit(len); 76 | *length -=2; 77 | *step+=2; 78 | } 79 | else if ((x==20)||(x==30)||(x==40)||(x==50)||(x==60)||(x==70)||(x==80)||(x==90)){ 80 | if(x==20){ 81 | printf("Twenty "); 82 | }else if(x==30){ 83 | printf("Thirty "); 84 | }else if(x==40){ 85 | printf("Fourty "); 86 | }else if(x==50){ 87 | printf("Fifty "); 88 | }else if(x==60){ 89 | printf("Sixty "); 90 | }else if(x==70){ 91 | printf("Seventy "); 92 | }else if(x==80){ 93 | printf("Eightty "); 94 | }else if(x==90){ 95 | printf("Ninety "); 96 | } 97 | unit(len); 98 | *length =*length-2; 99 | *step+=2; 100 | } 101 | else{ 102 | if((x>20)||(x<100)){ 103 | if ((x>20)&&(x<30)){ 104 | printf("Twenty "); 105 | } 106 | else if ((x>30)&&(x<40)){ 107 | printf("Thirty "); 108 | } 109 | else if ((x>40)&&(x<50)){ 110 | printf("Forty "); 111 | } 112 | else if ((x>50)&&(x<60)){ 113 | printf("Fifty "); 114 | } 115 | else if ((x>60)&&(x<70)){ 116 | printf("Sixty "); 117 | } 118 | else if ((x>70)&&(x<80)){ 119 | printf("Seventy "); 120 | } 121 | else if ((x>80)&&(x<90)){ 122 | printf("Eighty "); 123 | } 124 | else if ((x>90)&&(x<100)){ 125 | printf("Ninety "); 126 | } 127 | *length-=1; 128 | *step+=1; 129 | } 130 | } 131 | }; 132 | 133 | void once(int x,int* length, int* step,char amount[]){ 134 | if((*length==0)||(*length==2)||(*length==3)||(*length==5)||(*length==7)||(*length==9)){ 135 | if(amount[*step]!='0'){ 136 | if(amount[*step]=='1'){ 137 | printf("One "); 138 | }else if(amount[*step]=='2'){ 139 | printf("Two "); 140 | }else if(amount[*step]=='3'){ 141 | printf("Three "); 142 | }else if(amount[*step]=='4'){ 143 | printf("Four "); 144 | }else if(amount[*step]=='5'){ 145 | printf("Five "); 146 | }else if(amount[*step]=='6'){ 147 | printf("Six "); 148 | }else if(amount[*step]=='7'){ 149 | printf("Seven "); 150 | }else if(amount[*step]=='8'){ 151 | printf("Eight "); 152 | }else if(amount[*step]=='9'){ 153 | printf("Nine "); 154 | } 155 | unit(*length); 156 | *length-=1; 157 | *step+=1; 158 | }else{ 159 | *length-=1; 160 | *step+=1; 161 | } 162 | } 163 | } 164 | 165 | void twice(int* length, int* step ,char amount[]){ 166 | if ((*length==1)||(*length==4)||(*length==6)||(*length==8)) 167 | { 168 | char check[2]; 169 | check[0]=amount[*step]; 170 | check[1]=amount[*step+1]; 171 | check[2]='\0'; 172 | int ten = atoi(check); 173 | if (ten>10){ 174 | tenth(ten,*length,length,step); 175 | }else{ 176 | *length-=1; 177 | *step+=1; 178 | } 179 | } 180 | } -------------------------------------------------------------------------------- /C/sizeoffile.c: -------------------------------------------------------------------------------- 1 | // finding the size of a txt file 2 | #include 3 | #include 4 | 5 | int main(){ 6 | char line[1000]; 7 | int i=0; 8 | int count=0; 9 | int space=0,newline=0; 10 | FILE *fptr; 11 | fptr = (fopen("help.txt", "r")); 12 | 13 | while(1){ 14 | line[i] = fgetc(fptr); //READING CHARACTER FROM FILE 15 | if (line[i] == EOF) 16 | break; 17 | i++; 18 | 19 | } 20 | line[i]='\0'; // adding null at end 21 | 22 | while(line[count]!='\0'){ 23 | count++; 24 | } 25 | 26 | line[count]='\0'; 27 | i=0; 28 | while(i<=count){ 29 | if(line[i]=='\n'){ 30 | newline++; 31 | } 32 | i++; 33 | } 34 | printf("\nSize of the file is: %d bytes",newline+count); 35 | fclose(fptr); 36 | return 0; 37 | } -------------------------------------------------------------------------------- /C/stringReverse.c: -------------------------------------------------------------------------------- 1 | // reverse the given string 2 | #include 3 | #include 4 | int main(){ 5 | char name[7]="JAYDEEP" ; 6 | char rname[30]; 7 | int i,len,last; 8 | 9 | printf("Your name is Before reversing : %s \n",name); 10 | 11 | len = sizeof(name); 12 | last = len-1; 13 | printf("length of string: %d \n",len); 14 | 15 | for(i=0;i 2 | int main(){ 3 | int a,b; 4 | printf("Enter two values to swap : "); 5 | scanf("%d %d",&a,&b); 6 | // swaping value witout thrid variable 7 | a= a+b; 8 | b=a-b; 9 | a=a-b; 10 | printf("values after swaping : \n"); 11 | printf("value of a is : %d\n",a); 12 | printf("value of b is : %d\n",b); 13 | 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /C/triangle.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int n=15; 5 | int i,j,space; 6 | int ivar=97; 7 | for(i=0;i<=n;i++){ 8 | for(space=n-i;space>=0;space--){ 9 | printf(" "); 10 | } 11 | ivar=97; 12 | int ivar2 =65; 13 | for(j=0;j //preprocessor directive 2 | 3 | using namespace std; 4 | 5 | int main(){ //main function 6 | string name; 7 | cout<<"Please enter your Name: "; 8 | cin>>name; 9 | cout<<"Welcome to I-Tech Solutions): "< 2 | using namespace std; 3 | 4 | int main(){ 5 | cout<< "this is so dumb.without a new line at the end"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /CPP/01-Recursion/factorial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int factorial(int x){ 4 | if (x>0){ 5 | return x * factorial(x-1); //using recursion for finding the factorial 6 | }else { 7 | return 1; 8 | } 9 | }; 10 | 11 | int main(){ 12 | int n; 13 | cout<<"Input a numer to find the factorial: "; 14 | cin>>n; 15 | 16 | cout<<"facotrial of teh given nubmer is: "; 17 | cout< 2 | using namespace std; 3 | 4 | int sum(int n){ 5 | if (n > 0) { 6 | return n + sum(n-1); 7 | } 8 | else{ 9 | return 0; 10 | } 11 | } 12 | int main(){ 13 | int n; 14 | cout<< "Enter the number: "; 15 | cin>>n; 16 | cout<<"Sum of given number: "<< sum(n); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /CPP/02-OOPs/class.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | class Car { 5 | public: 6 | string name; 7 | string brand; 8 | string model; 9 | int year; 10 | string color; 11 | 12 | Car(string x,string y,int z,string c){ 13 | brand = x; 14 | model = y; 15 | year = z; 16 | color = c; 17 | } 18 | }; 19 | 20 | int main(){ 21 | Car Tata("Tata","Alto",2022,"Blabla"); 22 | Car Ford("Fortuner","Desert",2021,"White"); 23 | 24 | Tata.name= "Nexon"; 25 | Tata.color= "Red"; 26 | 27 | cout< 2 | #include 3 | using namespace std; 4 | 5 | // ifstream - reads from a file 6 | // ofstream - create and write to a file 7 | // fstream - a combo of ifstream and ofstream , can perfor CURD operations on file 8 | 9 | 10 | int main(){ 11 | ofstream myfile("demo.txt"); // creating a file named demo.txt and opening it 12 | 13 | myfile<<"file handling is tricky, but you can do some fun stuff too. ):"; //writing to the myfile.txt 14 | 15 | myfile.close(); //closing the file 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /CPP/03-FileHandling/fileOps.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main(){ 6 | int line; 7 | string text; 8 | ofstream countSpaces("demo2.txt"); 9 | 10 | while(countSpaces) 11 | cou 12 | 13 | countSpaces.close(); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /CPP/03-FileHandling/readfile.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main(){ 7 | string justaline; 8 | ifstream tfile("demo.txt"); 9 | while(getline(tfile,justaline)){ 10 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int x[10] = {1,54,47,27,66,87,25,31,74,10}; 7 | int i=0; 8 | int big; 9 | while(i<10){ 10 | big = ((x[i])<(x[i+1]))?x[i+1]:x[i]; //ternary oprator example >> if the given condition is true 11 | i++; //the first part will be executed and if not the second X 12 | }; //the first part will be executed and if not the second part will be executed 13 | 14 | cout<<"Biggest number of given array is: "< 2 | using namespace std; 3 | 4 | class Parent{ 5 | public: 6 | void poly(){ 7 | cout<<"Inside the Parent class"; 8 | } 9 | }; 10 | 11 | class Child : public Parent{ 12 | public: 13 | void poly(){; 14 | cout<<"Insite the Child class"; 15 | } 16 | 17 | }; 18 | 19 | int main(){ 20 | Child x; 21 | x.poly(); 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /CPP/05-Polymorphism/functionoverloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void add(int x, int y){ 5 | cout<< "x + y = "< 2 | using namespace std; 3 | 4 | class opOverloading{ 5 | 6 | }; 7 | 8 | int main(){ 9 | // sum of integers 10 | cout<<"sum of numbers: "< 6 | using namespace std; 7 | // By Default all class member are private 8 | class AccessSpecifier{ 9 | 10 | public: //class member can be accessed by outside of the class 11 | string pname = "First Player"; 12 | 13 | private: //class member can not be accessed and viewd by outside of the class 14 | int pnumber = 9809809809; 15 | 16 | protected: //class member can be accessed by outside of the class 17 | string address = "Bhot dur hai"; 18 | }; 19 | 20 | int main(){ 21 | AccessSpecifier Ashok; 22 | cout<<"Name of first Player: "<