├── README.md ├── Control structures in C++ ├── While Loop Practice.cpp ├── Do while Loop Practice.cpp ├── For Loop: 1 to 100 except 3 table.cpp ├── For Loop.cpp ├── Vowel Practice.cpp ├── Practice: Break and Continue Statement.cpp ├── Switch Case.cpp ├── If Else Ladder.cpp └── Calculator using While Loop.cpp ├── Data types in C++ ├── Practice 1.cpp ├── Practice 3.cpp └── Practice 2.cpp ├── Reference varaibles in C++.cpp ├── Structures, Unions and Enumerations in C++ ├── Practice 3 Enum.cpp ├── Practice 2: Union.cpp └── Practice 1: Structure.cpp ├── Pattern Questions ├── Inverted half pyramid ├── Rectangle Pattern.cpp └── Hollow rectangle pattern.cpp ├── Input and output practice.cpp ├── Recursive Functions in C++ ├── Practice 1 Sum Function.cpp ├── Practice 4 nth Fibonacci Function.cpp ├── Practice 2 Power Function.cpp ├── Practice 3 Factorial Function.cpp └── Practice 5 Increasing and Decreasing Function.cpp ├── Pointers in C++ └── Practice 1.cpp ├── Functions in C++ ├── Factorial Function.cpp ├── Even and Odd Function.cpp ├── Binary Coefficient Function.cpp ├── Fibonacci Series Function.cpp ├── Checking for Voting Function.cpp ├── Prime Number Function.cpp ├── Alphabet Checking Function.cpp ├── Swap the Values Function.cpp ├── Inline Function.cpp ├── Maxima and Minima Function.cpp └── Nesting Member Function.cpp ├── Call by value and Call by Reference in C++.cpp ├── Typecasting Practice.cpp ├── Default Argument and Constant Argument.cpp ├── Arrays in C++ └── Practice 1.cpp ├── Object Oriented Programming Concepts in C++ ├── Practice 1 Constructors .cpp └── Practice 1 Class Concepts.cpp └── Operators in C++ └── Usage of Operators.cpp /README.md: -------------------------------------------------------------------------------- 1 | # C-Projects 2 | This repo contains the code of C++ which is for absolute beginners who are learning programming first time in their respective institution or university. 3 | -------------------------------------------------------------------------------- /Control structures in C++/While Loop Practice.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() {int i=1,n=6; 4 | while(i<=10){cout< 2 | using namespace std; 3 | int main() { int i=1,n=6; 4 | do {cout< 2 | using namespace std; 3 | int main() { 4 | int a=4; 5 | int b=30; 6 | cout<<"this is tutorial 4 . this is value of a"< 2 | using namespace std; 3 | int c=46; 4 | int main() { 5 | float x=455; 6 | float&y=x; 7 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | for(int i=0;i<100;i++){ 6 | if(i%3==0){ 7 | continue; 8 | } 9 | cout< 2 | using namespace std; 3 | int main(){ 4 | enum days{monday,tuesday,wednesday,thursday,friday,saturday,sunday}; 5 | days d1=monday; 6 | cout< 2 | using namespace std; 3 | int main() { 4 | int n; 5 | cin>>n; 6 | for (int i=n;i>1;i--){ 7 | for(int j=1;j<=i;j++){ 8 | cout<<"*"; 9 | } 10 | cout< 2 | using namespace std; 3 | int main () { 4 | int num1 , num2; 5 | cout<<"the value of number 1 is"; 6 | cin>>num1; 7 | cout<<"the value of number 2 is"; 8 | cin>>num2; 9 | cout<<"the sum is"< 2 | #include 3 | using namespace std; 4 | int main() { 5 | int rows,col; 6 | cin>>rows>>col; 7 | for(int i=1;i<=rows;i++){ 8 | for(int j=1;j<=col;j++){ 9 | cout<<"8"; 10 | } 11 | cout< 2 | using namespace std; 3 | int sum(int n){ 4 | if(n==0){ 5 | return 0; 6 | } 7 | int prevsum=sum(n-1); 8 | return n+prevsum; 9 | } 10 | int main(){ 11 | int n; 12 | cin>>n; 13 | cout< 2 | using namespace std; 3 | 4 | int fib(int n){ 5 | if(n==0||n==1){ 6 | return n; 7 | } 8 | return fib(n-1)+fib(n-2); 9 | } 10 | 11 | int main(){ 12 | int n; 13 | cin>>n; 14 | cout< 2 | using namespace std; 3 | int main() { 4 | int a=14; 5 | int*b=&a; 6 | cout<<"the address of a is"<<&a< 2 | using namespace std; 3 | 4 | int power(int n,int p){ 5 | if (p==0) 6 | return 1; 7 | int prevpower=power(n,p-1); 8 | return n*prevpower; 9 | } 10 | int main(){ 11 | int n,p; 12 | cin>>n>>p; 13 | cout< 2 | using namespace std; 3 | union balance{ 4 | float currentamount; 5 | float totalamount; 6 | 7 | }; 8 | int main(){ 9 | balance b1; 10 | b1.currentamount=34; 11 | cout<<"current amount of b1 "< 2 | using namespace std; 3 | int main(){ 4 | int a,b; 5 | for(a=1;a<=10;a++){ 6 | cout< 2 | using namespace std; 3 | 4 | int factorial(int n){ 5 | if(n==0) 6 | return 1; 7 | int prevfactor=factorial(n-1); 8 | return n*prevfactor; 9 | } 10 | int main(){ 11 | int n; 12 | cin>>n; 13 | cout< 2 | using namespace std; 3 | int fact(int n){ 4 | int factorial=1; 5 | for(int i=1;i<=n;i++){ 6 | factorial*=i; 7 | } 8 | return factorial; 9 | } 10 | int main(){ 11 | int n; 12 | cin>>n; 13 | int ans=fact(n); 14 | cout< 2 | using namespace std; 3 | int evodd(int n){ 4 | 5 | if(n%2==0){ 6 | cout<<"even"<>n; 16 | evodd(n); 17 | return 0; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Control structures in C++/Vowel Practice.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main(){ 5 | char c; 6 | cout<<"Enter any chacter\n"; 7 | cin>>c; 8 | if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u') 9 | 10 | cout<<"vowel"; 11 | 12 | 13 | else 14 | cout<<"consonent"; 15 | 16 | getch(); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /Functions in C++/ Binary Coefficient Function.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int fact(int n){ 4 | int factorial=1; 5 | for(int i=2;i<=n;i++){ 6 | factorial*=i; 7 | 8 | } 9 | return factorial; 10 | } 11 | int main(){ 12 | int n,r; 13 | cin>>n>>r; 14 | int ans=fact (n)/fact(r)*fact(n-r); 15 | cout< 2 | using namespace std; 3 | int main(){ 4 | 5 | int rows,col; 6 | cin>>rows>>col; 7 | for(int i=1;i<=rows;i++){ 8 | for(int j=1;j<=col;j++){ 9 | if(i==1||i==rows||j==1||j==col){ 10 | cout<<"*";} 11 | else { 12 | cout<<" "; 13 | } 14 | } 15 | cout< 2 | using namespace std; 3 | void fib(int n){ 4 | int t1=0; 5 | int t2=1; 6 | int nextterm; 7 | for(int i=1;i>n; 19 | fib(n); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /Control structures in C++/Practice: Break and Continue Statement.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int pocketmoney=3000; 6 | for(int date=1;date<=30;date++){ 7 | if(date%2==0){ 8 | continue; 9 | } 10 | if (pocketmoney==0){ 11 | break; 12 | }cout<<" go out today! "< 2 | using namespace std; 3 | int voting(int age){ 4 | if(age>=18){ 5 | cout<<"you are eligible for voting legally"<>age; 15 | voting(age); 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Functions in C++/Prime Number Function.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std ; 4 | bool prime(int n){ 5 | for(int i=2;i>a>>b; 16 | for(int i=a;i<=b;i++){ 17 | if(prime(i)){ 18 | cout< 2 | using namespace std; 3 | char alpha(char a){ 4 | if(a>='a'&&a<='z') 5 | cout<<"alphabet"<='A'&&a<='Z') 7 | cout<<"alphabet"<>a; 17 | alpha(a); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Functions in C++/Swap the Values Function.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int swap(int a,int b){ 4 | cout<<" the value of a before "< 2 | using namespace std; 3 | 4 | void dec(int n ){ 5 | if(n==0){ 6 | return; 7 | } 8 | cout< 3 | using namespace std; 4 | int main() { 5 | //int a=4; 6 | //int b=30; 7 | //cout<<"this is tutorial 4 . this is value of a "< 2 | using namespace std; 3 | int sum(int a,int b){ 4 | int c=a+b; 5 | return c; 6 | } 7 | void swap(int*a, int*b){ 8 | int temp=*a; 9 | *a=*b; 10 | *b=temp; 11 | } 12 | int main(){ 13 | int x=4; 14 | int y=5; 15 | cout<<"the value of x is"< 2 | using namespace std; 3 | int c=46; 4 | int main() { 5 | int a=46.9; 6 | float b=13; 7 | cout<<"the value of a is "<<(int)a< 2 | using namespace std; 3 | float moneyreceived(int currentmoney,float factor=1.04){ 4 | return currentmoney*factor; 5 | } 6 | int main(){ 7 | int money=100000; 8 | cout<<"if you have "< 2 | using namespace std; 3 | struct store{ 4 | 5 | int itemscarreid; 6 | float totalbill; 7 | float tax; 8 | }; 9 | int main(){ 10 | store adil; 11 | adil.itemscarreid=3; 12 | adil.totalbill=3400; 13 | adil.tax=3.4; 14 | cout<<"the value of adil's items carried"< 2 | using namespace std; 3 | int main() { 4 | int marks; 5 | cout<<"enter your marks"; 6 | cin>>marks; 7 | switch(marks) 8 | { 9 | case 40: 10 | cout<<"you are just pass"< 2 | using namespace std; 3 | int main() { 4 | int marks[]={13,15,39,98}; 5 | cout< 2 | using namespace std; 3 | int main() { 4 | int marks; 5 | cout<<"enter your marks"; 6 | cin>>marks; 7 | if(marks<40){cout<<"you are fail reattempt it"<40)&&(marks<60)){cout<<"you are jsut pass. hard work now "<60)&&(marks<80)){cout<<"just fair "<80)&&(marks<90)){cout<<"keep it up (good) "<90){cout<<"excellent "< 2 | using namespace std; 3 | class employee{ 4 | public: 5 | string name; 6 | string company; 7 | int age; 8 | void yourself(){ 9 | cout<<"Name -"< 2 | using namespace std; 3 | inline int product(int a,int b){ 4 | return a*b; 5 | } 6 | int main(){ 7 | int a,b; 8 | cout<<"enter the value of a and b"<>a>>b; 10 | cout<<"the product of a and b is "< 2 | using namespace std; 3 | 4 | int maxima(int i,int j,int k){ 5 | if(i>j&&i>k){ 6 | cout<<" first number is greatest"<k&&j>i){ 9 | cout<<"second number is greatest"<i&&k>j){ 12 | cout<<"third number is greatest"<>i>>j>>k; 35 | maxima(i,j,k); 36 | minima(i,j,k); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /Control structures in C++/Calculator using While Loop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main () { bool r=1; 4 | while(r>0){ 5 | 6 | char a; 7 | float x,y; 8 | cout<<"entere the first number"<>x; 10 | cout<<"enter the second number "<>y; 12 | cout<<"perfrom any arthmetic number"<>a; 14 | if(a='+') { 15 | 16 | cout<<"the addition of x and y is "<>r; 30 | 31 | } return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Object Oriented Programming Concepts in C++/Practice 1 Class Concepts.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | class Animals{ 5 | private: 6 | string lion,tiger,cheetah; 7 | public: 8 | string ligris,leopard; 9 | void setdata(string lion1,string tiger1,string cheetah1); 10 | void getdata(){ 11 | cout<<"the few sweat glands animal is "< 2 | #include 3 | using namespace std; 4 | class binary 5 | { 6 | private: 7 | string s; 8 | public: 9 | void read(void); 10 | void chkbin(void); 11 | void onescompliment(void); 12 | void display(void); 13 | }; 14 | void binary::read(void) 15 | { 16 | cout<<"enter a binary number"<>s; 18 | } 19 | void binary::chkbin(void) 20 | { 21 | 22 | for(int i=0;i 2 | using namespace std; 3 | int main () { 4 | int a=4, b= 6; 5 | //using first arthemetic operators 6 | cout<<"the value of a+b= "<=b is "<<(a>=b)<b is "<<(a>b)<