27 Mart 2017 Pazartesi

C Program to Shutdown or Turn Off the Computer in Linux

QT den Linux yada Windows ortamına komutlar gönderebiliriz .Örnegin sistemi kapatmak istersek ;


  1. /*
  2.  * C Program to Shutdown or Turn Off the Computer in Linux.
  3.  */
  4. #include 
  5.  
  6. int main()
  7. {
  8.     system("shutdown -P now");
  9.     return 0;
  10. }

Eğer Windowsta bilgisayarı kapatıp acmak istersek komut olarak ; "shutdown /s" komutunu gndeririz .
Share:

QT BINARY CONVERT TO DECIMAL

#include "binary_convert.h"
#include
Binary_Convert::Binary_Convert()
{

}
void Binary_Convert::bin_con()
{

    int num,binary_val ,decimal=0,base=1,rem;
    std::cout << " Please Binary Value : ";
    std::cin>>num;
    binary_val=num;

    while(num>0)
    {
        rem=num%10;
        decimal=decimal+rem*base;
        num=num/10;
        base=base*2;
    }
    std::cout << "\n Binary Value is   : "<< binary_val;
    std::cout<<  "\n Decimal Value is  : "<< decimal;


}
Share:

QT FRIEND FUNCTION

#include
#include
class  base
{
    int val1,val2;
   public:
    void get()
    {
       cout<<"Enter two values:";
       cin>>val1>>val2;
    }
    friend float mean(base ob);
};
float mean(base ob)
{
   return float(ob.val1+ob.val2)/2;
}
void main()
{
    clrscr();
    base obj;
    obj.get();
    cout<<"\n Mean value is : "<
    getch();
}          

Output:

Enter two values: 10, 20
Mean Value is: 15
Share:

QT BAŞKA CLASSTAN FONKSIYON ÇAGIRMA



CLASS


#include "func.h"
#include
func::func()
{

}
void func::printmessage()
{
    std::cout << "I am a Function ";
}






----------------------------------------------------------------------------------------------------------------





ANA YAPI 


#include 
#include
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    func object;                               // CLASSTAN BİR OBJECT OLUŞTURUP CAGIRIYORUZ
    object.printmessage();    
    return a.exec();
}

Share:

QT CONSTRUCTOR

Syntax

class class-name
{
    Access Specifier:
        Member-Variables
        Member-Functions
    public:
        class-name()
        {
            // Constructor code 
        }
         class-name(variables)
        {
            // Constructor code 
        }
        ... other Variables & Functions
}

Example Program

/*  Example Program For Simple Example Program Of Constructor Overloading In C++
    little drops @ thiyagaraaj.com

    Coded By:THIYAGARAAJ MP             */

#include
#include

using namespace std;

class Example        {
    // Variable Declaration
    int a,b;
    public:

    //Constructor wuithout Argument
    Example()            {
    // Assign Values In Constructor
    a=50;
    b=100;
    cout<<"\nIm Constructor";
    }

    //Constructor with Argument
    Example(int x,int y)            {
    // Assign Values In Constructor
    a=x;
    b=y;
    cout<<"\nIm Constructor";
    }

    void Display()    {
    cout<<"\nValues :"<
    }
};

int main()                {
        Example Object(10,20);
        Example Object2;
        // Constructor invoked.
        Object.Display();
        Object2.Display();
        // Wait For Output Screen
        getch();
        return 0;
}

Sample Output

Im Constructor
Im Constructor
Values :10      20
Values :50      100
Share:

QT IS CAPITAL IS DIGITAL IS SMALL CHARACTER

#include "iscapital_isdigit_issmall.h"
#include
IsCapital_IsDigit_IsSmall::IsCapital_IsDigit_IsSmall()
{

    char character;
    std::cout << " Enter A Character : ";
    std::cin>>character;


    int storeAscii = character;


    std::cout << "The Ascii Value of   :    "<< character << "        is          "<< storeAscii ;


    if (storeAscii>=65 && storeAscii<=90)
      {
        std::cout<<"\nYou have entered a capital letter";
      }

      else if (storeAscii>=97 && storeAscii<=122)
      {
        std::cout<<"\nYou have entered a small letter";
      }

      else if (storeAscii>=47 && storeAscii<=57)
      {
        std::cout<<"\nYou have entered a digit ";
      }

      else if (storeAscii>=0 && storeAscii>=47
          || storeAscii>=54 && storeAscii<=64
          || storeAscii>=91 && storeAscii<=96
          || storeAscii>=123 && storeAscii<=127)
      {
        std::cout<<"\nYou have entered a special character";
      }


}


Share:

QT FIBONACCI

#include "fibo.h"
#include
fibo::fibo()
{
   int range,first=0,second=1,tmp;

   std::cout << "Please Fibonacci Ranger : ";
   std::cin>>range;


   for(int c =0; c < range ; c++)
   {
       if(c<=1)
       {
           second = c;
       }
       else
       {
           tmp = second;
           second = first+second;
           first = tmp ;
       }
       std::cout<< second <<"  ,  \t  ";
   }




}
Share: