Saturday, May 28, 2022

USING POINTER ARTHMETICS #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int A[5]={2,4,6,8,10};

    int *p=A;

    

    cout<<*p<<endl;

    p++;

    cout<<*p<<endl;

    p--;

    cout<<*p<<endl;

    return 0;

}

DYNAMIC MEMORY USING POINTER IN HEAP #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int *p=new int[5];

    p[0]=12;

    p[1]=13;

    cout<<p[3]<<endl;

    

    

    delete []p;

    p=nullptr;

    return 0;

}

program for dynamic allocation #THEHACKERS@

 # include<iostream>

using namespace std;

   

int main()

{


int size;

cout<<"enter no of element";

cin>>size;

int a[size];

cout<<sizeof a<<endl;

    return 0;

}

Friday, May 20, 2022

POINTERS AND THEIR ADDRESS #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int a=10;

    int *p=&a;

    

    

    cout<<a<<endl;

    cout<<&a<<endl;;

    cout<<p<<endl;

    cout<<&p<<endl;

    cout<<*p<<endl;

    return 0;

    

}

NEW PATTERN USING NASTED FOR #THEHACKERS@

 #include<iostream>

using namespace std;



int main()

{

    int i;

    for(i=0;i<9;i++)

    {

        for(int j=0;j<9;j++)

        {

            if(i+j>9-1)

            {

                cout<<" * ";

            }

        }

        cout<<endl;

    }

    return 0;

}

PRINTING ASTRICKS USING ARRAY #THEHCKERS@

 #include<iostream>

using namespace std;



int main()

{

    int i;

    for(i=0;i<4;i++)

    {

        for(int j=0;j<4;j++)

        {

            if(i>j)

            {

                cout<<" * ";

            }

        }

        cout<<endl;

    }

    return 0;

}

Thursday, May 19, 2022

2-D ARRAY #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int i,j;

    cout<<" enter i:";

    cin>>i;

    cout<<" enter j:";

    cin>>j;

    for(i=0;i<5;i++)

    {

        for(j=0;j<5;j++)

        {

            

        }

    }

    cout<<i<<j;

    return 0;

}

SUM OF an array #THEHACKERS@

 #include<iostream>

using namespace std;



int main()

{

    int A[7]={12,15,67,45,56,67,78};

    int n=7,sum=0;

    for(int i=0;i<7;i++)

    {

        sum=sum+A[i];

    }

    cout<<" The sum is:"<<sum;

    return 0;

}

ARRAY #THEHACKERS@

#include<iostream>

using namespace std;


int main()

{

    int A[5]={19,20,50,39};

    for(int i=0;i<5;i++)

    {

        cout<<A[i]<<endl;

    }

    return 0;

} 

TO CHECK THE NO IS PARDONILM OR NOT #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int n,num, digit,rev=0;

    cout<<" enter the positive number :";

    cin>>num;

    n=num;

    do

    {

     digit = num%10;

     rev = (rev*10)+digit;

     num=num/10;

    }while(num!=0);

    

    cout<<" the rev of the no is :"<<rev<<endl;

    if(n == rev)

    {

        cout<<" the number is pardorilm";

    }

    else

    {

        cout<<" the number is not pardorilom";

    }

    return 0;

    

}

Tuesday, May 17, 2022

COPING ANOTHER FILE #THEHACKERS@

 #include <iostream>

#include <fstream> using namespace std; int main() { string line; //For writing text file //Creating ofstream & ifstream class object ifstream ini_file {"original.txt"}; ofstream out_file {"copy.txt"}; if(ini_file && out_file){ while(getline(ini_file,line)){ out_file << line << "\n"; } cout << "Copy Finished \n"; } else { //Something went wrong printf("Cannot read File"); } //Closing file ini_file.close(); out_file.close(); return 0; }

Sunday, May 15, 2022

TO CHECK ARMSTRONG NUMBER #THEHACKERS@

 #include<stdio.h>

#include<math.h>

int main()

{

    int i,num,r,sum=0,count=0;

    printf("enter a number::");

    scanf("%d",&num);

    while(num!=0)

    {

   count++;

   num=num/10;

   

}

while(num!=0)

{

    r=num%10;

    num=num/10;

    sum+=pow(r,count);

    num=num/10;

}

if(num==sum)

{

printf("number is armstrong number");

}

else

{

printf("not a armstrong number");

}

return 0;

}

Saturday, May 14, 2022

CHECKING AMSTRONG NUMBER #THEHACKERS@

 #include<iostream>


using namespace std;

int main()


{

    int n,r,sum=0,m;

    cout<<" enter n:";

    cin>>n;

    m=n;

    while(n>0)

    {

        r=n%10;

        n=n/10;

        sum=sum+r*r*r;

    }

    if(sum==sum)

    {

        cout<<" this is a amstong ";

    }

    else

    {

        cout<<" not amstrong no";

    }

    return 0;

}

PRINTING PRIME NUMBER #THEHACKERS@

 #include<iostream>


using namespace std;

int main()


{

    int n;

    int count=0;

    cout<<" enter n:";

    cin>>n;

    

    for(int i=1;i<=n;i++)

    {

        if(n%i==0)

            count++;

    }

    

    if(count==2)

        cout<<"prime";

    else

        cout<<"not prime";

}

Wednesday, May 11, 2022

MULTIPLICATION TABLE USING FOR LOOP #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int n, i;

    cout<<" Enter n:";

    cin>>n;

    for(i=1;i<=20;i++)

    {

        cout<<n<<" x "<<i<<" = "<<i*n;

        cout<<endl;

    }

    return 0;

}

DO WHILE LOOP #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int n, i=1;

    cout<<" Enter n:";

    cin>>n;

   do

    {

        cout<<i<<endl;

        ++i;

    } while(i<=10);

    return 0;

}

Monday, May 9, 2022

TO FIND LEAP YEAR BY USING CONDITIONAL STATEMENT #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int year;

    cout<<" Enter the year:";

    cin>>year;

    if(year % 4 == 0)

    {

        if(year % 100 == 0)

        {

            if(year % 400 ==0)

            {

                cout<<" this a leap year.";

            }

            else

            {

                cout<<" this is not a leap year.";

            }

        }

        else

        {

            cout<<" this is a leap year.";

        }

    }

    else

    {

      cout<<" this is not a leap year.";  

    }

    return 0;

}

Sunday, May 8, 2022

THE DAM #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int a, b;

    cout<<" Enter a:";

    cin>>a;

    cout<<" Enter b:";

    cin>>b;

    int c;

    if(c<10)

    {

        cout<<" True";

    }

    else

    {

        c>10;

        cout<<" False";

    }

    return 0;

}

Friday, May 6, 2022

SWITCH CASE USING TO FIND OUT DAYS #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int day;

    cout<<" Enter your day no :";

    cin>>day;

    switch(day)

    {

        case 1:cout<<" Monday";

        break;

        case 2:cout<<" Tuesday";

        break;

        case 3:cout<<" Wednesday";

        break;

        case 4:cout<<" Thrusday";

        break;

        case 5:cout<<" Friday";

        break;

        case 6:cout<<" Saturday";

        break;

        case 7:cout<<" Sunday";

        break;

    }

    return 0;

}

DYANAMIC MEMORY DECLARATION #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int a=10, b=5;

    if(true)

    {

        int c=a+b;

        cout<<c<<endl;

    }

    return 0;

}

Thursday, May 5, 2022

ENTER YOUT NO. YOU WILL GET YOUR DAY #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int day;

    cout<<" Enter your day no. :";

    cin>>day;

    if(day==1)

    {

        cout<<" Monday ";

    }

    else

    {

        if(day==2)

        {

            cout<<" Tuesday";

        }

        else

        {

            if(day==3)

            {

                cout<<" Wednesday";

            }

            else

            {

                if(day==4)

                {

                    cout<<" Thrusday";

                }

                else

                {

                    if(day==5)

                    {

                        cout<<" Friday";

                    }

                    else

                    {

                        if(day==6)

                        {

                            cout<<" Saturday";

                        }

                        else

                        {

                            day==7;

                            cout<<" Sunday";

                        }

                    }

                }

            }

        }

    }

    return 0;

}

AVERAGE OF STUDENTS USING NEASTED IF #THEHACKERS@

 #include<iostream>

using namespace std;


int main()

{

    int m1, m2, m3, total;

    float avg;

    cout<<" Enter m1 :";

    cin>>m1;

    cout<<" Enter m2 :";

    cin>>m2;

    cout<<" Enter m3 :";

    cin>>m3;

    total=m1+m2+m3;

    avg=total/3.0;

    if(avg>=60)

    {

        cout<<" YOUR GARDE IS A,";

    }

    else

    {

        if(avg>=35&&avg<60)

        {

            cout<<" YOUR GARDE IS B.";

        }

        else

        {

            cout<<" YOUR GRADE IS C.";

        }

    }

    return 0;

    

    

}

Creating and writing in the file and save it too . #THEHACKERS@

 #include <fstream>

#include <iostream>

using namespace std;

 

int main () {

   char data[100];


   ofstream outfile;

   outfile.open("Hassu.txt");


   cout << "Writing to the file" << endl;

   cout << "Enter your name: "; 

   cin.getline(data, 100);


   outfile << data << endl;


   cout << "Enter your age: "; 

   cin >> data;

   cout<<" Enter your id: ";

   cin>>data;

   cout<<" Enter your code: ";

   cin>>data;

   cin.ignore();

   

   outfile << data << endl;


   outfile.close();


   ifstream infile; 

   infile.open("Hassu.txt"); 

 

   cout << "Reading from the file" << endl; 

   infile >> data; 


   cout << data << endl;

   

   infile >> data; 

   cout << data << endl; 


   infile.close();


   return 0;

}

Wednesday, May 4, 2022

Using Natested If condition in finding age #THEHACKERS@

#include<iostream>

using namespace std;


int main()

{

    int age;

    cout<<" Enter your age : ";

    cin>>age;

    if(age>=18&&age<=45)

    {

        cout<<" You are young, ";

    }

    else

    {

        if(age>45)

        {

            cout<<" You are old.";

        }

        else

        {

         (age<18);

         cout<<" You are not mature. ";   

        }

    }

    return 0;

} 

Tuesday, May 3, 2022

Condition operator #THEHACKERS@

#include<iostream>

using namespace std;


int main()

{

    int a,b,c;

    cout<<" Enter a :";

    cin>>a;

    cout<<" Enter b :";

    cin>>b;

    if(a<b)

    {

        cout<<" Ture ";

    }

    else

    {

        a>b;

        cout<<" False ";

    }

    return 0;

} 

Sunday, May 1, 2022

Open and close file #THEHACKER@

 #include <iostream>

#include <fstream>

using namespace std;

int main() {

fstream my_file;

my_file.open("my_file.txt ", ios::trunc);

 

return 0;

}

CONSTRUCTURE IN PARENT CLASS

class Parent {     public Parent()     {         System.out.println("Parent Constrcutor");     }              } class Child extend...