Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

#INCLUDE<STDIO.H> #INCLUDE<CONIO.H> MAIN() { INT N, sq, cu, fo, fi; clrscr(); prinf("enter a number : ") scanf("%d", &n); sq = n * n; cu = n * n * n; fo = sq * sq; fi = sq * cu; printf("square = %d\n", sq); p

cpp

#include<stdio.h>
#include<conio.h>
main()
{
int N, sq, cu, fo, fi;
clrscr();
prinf("enter a number : ")
scanf("%d", &n);
sq = n * n;
cu = n * n * n;
fo = sq * sq;
fi = sq * cu;
printf("square = %d\n", sq);
printf("cube = %d\n", cu);
printf("forth = %d\n", fo);
printf("fifth = %d\n", fi);
getch();
}

Compile and Execute C++ Online

cpp

#include<iostream>
using namespace std;

double getUnitprice(int itemCode);

int main(){

  double invoice[10][4];
  int i=0; char more; char date[100];

  cout << "\n\n********* Here are the Item prices for your information********** \n\nItem code\tUnitPrice\n\n1\t100\n2\t200\n3\t300\nInvalidCode\t0\n\n";
  cout << "Enter the date: ";
  cin >> date;
  
  do {
 
    cout << "\n\nItem code: ";
    cin >> invoice[i][0];
    cout << "Quantity : ";
    cin >> invoice[i][1];
    
    invoice[i][2] = getUnitprice(invoice[i][0]); 
    invoice[i][3] = invoice[i][1] * invoice[i][2]; 
    
    cout << "Do you have any other items to be entered next (y/n) ? ";
    cin >> more;
  
    i++;
  } while(more == 'y');
    
 
  cout << "\n\n-----------------------------\n\n";
  cout << "Date : " << date << "\n\n";
  
  cout << "ItemCode|Quantity|UnitPrice|TotalPrice\n\n";
  int tot=0;
  for(int k=0; k<i; k++)   
    
	{
		for(int l=0; l<4; l++) 
		{
		    cout << invoice[k][l]  << "\t";		   
		}
		cout << endl;
		tot = tot + invoice[k][3];
	}

  cout << "\n\nTotal : " << tot;
  cout << "\n\n-----------------------------\n\n\n";
  
  return 0;
}

double getUnitprice(int itemCode){
  double price;
  switch (itemCode)
  {
    case 1: price = 100;
      break; 
    case 2: price = 200;
      break;
    case 3: price = 300;
      break;
    default: price = 0;
      break;
  }
  return price;
}

CellPhone Actividades con los celulares

cpp

#include <iostream>
//#include "Celular.h"
#include "ArrCelular.h"  //El archivo ArrCelular llama al Celular.h
//#include "ListaCelular.h"
using namespace std;

int main()
{
	CArrCelular* arreglo;    //Crea un objeto del tipo arreglo
	arreglo = new CArrCelular();//el objeto es de tipo PUNTERO
	CCelular* objDinamic1 = new CCelular((char*)("Black Berry"), 94653212, 13246789);
	arreglo->insertar(objDinamic1);  // Método ... se usa -> porque es Puntero
	
	CCelular* objDinamic2 = new CCelular((char*)("LG"), 94653214, 13246789);
	arreglo->insertar(objDinamic2);

	//Cout arreglo
	cout << arreglo->recuperar(0)->getMarca() << " " <<  //devuelve el OBJETO celular
		arreglo->recuperar(0)->getNumero() << " " <<
		arreglo->recuperar(0)->getImei() << " " << endl;
	
	CCelular* tmp;
	tmp = arreglo->recuperar(1);
	//cout<<tmp->getMarca()
	cout << "Marca : " << tmp->getMarca() << " Num : " << tmp->getNumero() << " Imei : " << tmp->getImei() << endl;
	cout << "La cantidad de celulares es: " << arreglo->getLongitud()<< endl;
	cout << "La posición del Nro de celular en el arreglo es: " << arreglo->buscar(94653212) << endl;
	arreglo->eliminarPorPosicion(0);
	cout << "La cantidad de celulares es: " << arreglo->getLongitud()<< endl;
	arreglo->eliminarTodo();
	cout << "La cantidad de celulares es: " << arreglo->getLongitud()<< endl;

	getchar();

tester_exercice_c++_fichier_somme_count_order

cpp

#include <iostream>

using namespace std;

int main()
{
   cout << "Hello World" << endl; 
   
   return 0;
}

Compile and Execute C++ Online

cpp

# include <iostream>

using namespace std;

void mightGoWrong()
{
	bool error = true;

	if (error)
	{
		throw "Something went wrong!";
	}
}

int main()
{
	try
	{
		mightGoWrong();
	}
	catch (int e)
	{
		cout << "Error code: " << e << endl;
	}
	catch (char const *e)
	{
		cout << "Error message: " << e << endl;
	}
	
	cout << "Hit [Enter] to exit ...";
	cin.get();

	return 0;
}

Compile and Execute C++ Online

cpp

#include  <iostream>

using namespace std;
int main(){
 int suma();
  int mult();
 int  resta();
  int division();

   return 0;
}
int suma (int a, int b){
    int sumar; 
    sumar = a+b;
    printf("Introduce el numero 1: ");
    scanf("%d",&a);
    printf("Introduce el numero 2: ");
    scanf("%d",&b);
    printf("la suma es:%d",sumar);
    return sumar;
}
int mult (int a, int b, int c){
    int multiplicacion;
    multiplicacion= suma(a,b)*c;
    printf("Introduce el numero para que se multiplique con el resultado de la suma: ");
    scanf("%d",&c);
    printf("la multiplicacion es :%d", multiplicacion);
    return mult;
}
int resta (int a, int b, int c, int d){
    int resta1;
    resta1 = mult (a,b)*c-d;
    printf("Introduce el numero para que se reste con el resultado de la multiplicacion: ");
    scanf("%d",&d);
    printf("la resta es :%d", resta1);
    return resta;
}
int divicion (int a, int b, int c, int d){
    double divicion1;
    division1= resta (((a,b)*c)-d)/3;
    printf("la divicion es :%d",divicion1);
    return divicion;
}

Compile and Execute C++ Online

cpp

#include <iostream>
using namespace std;
class InToPost
{
   char *infx,*pofx,*s,ch,elem;
   int top,size;
   int i,j;
   char temp;
   public:
	
     void push(char elem);
     char pop();
     void convert();
     int prec(char elem);
     InToPost()
     {
	top = -1;
	cout<<"enter size of the string"<<endl;
	cin>>size;
	infx=new char[size]; 
	pofx=new char[size];
	s=new char[size];
	cout<<"read the infix expression ? ";
	cin>>infx;
     }
};
void InToPost::push(char elem) 
{
 s[top] = elem;
 top++;
}


char InToPost:: pop() 	
{
    top--;
 return (s[top]);
}

/* Write code in convert() to convert infix to postfix expr */
int InToPost::prec(char elem)
{
    if(elem=='(')
    {
        return 1;
    }
    if(elem=='+'||elem=='-')
    {
        return 2;
    }
    if(elem=='*'||elem=='/')
    {
        return 3;
    }
}
void InToPost::convert()
{
    for(i=0;i<size;i++)
    {
        if(infx[i]!='+'&&infx[i]!='-'&&infx[i]!='*'&&infx[i]!='/'&&infx[i]!='(')
        {
            pofx[j++]=infx[i];
        }
        else
        {
            if(top==0)
            {
                push(infx[i]);
            }
            else
            {
                if(infx[i]!='(')
                {
                    if(prec(infx[i])<=prec(s[top-1]))
                    {
                        temp=pop();
                        pofx[j++]=temp;
                        push(infx[i]);
                    }
                    else
                    {
                        push(infx[i]);
                    }
                }
                    else
                    {
                        if(infx[i]=='(')
                        {
                            push(infx[i]);
                        }
                    }
                }
            }
        }
        while(top!=0)
        {
            pofx[j++]=pop();
        }
        cout<<infx<<endl;
        cout<<pofx<<endl;
}
/*
  Write code here to find the precedence of the operators as indicated below
  # = 0, ( = 1, +,- = 2, *,/ = 3 using function int prec(char elem);
*/


int main()
{
 char ch;
 int i = 0, k = 0;
 InToPost ip;
 ip.push('#');
 ip.convert();
 return 0;
}

Compile and Execute C++ Online

cpp

#include<iostream>
#include<algorithm>
using namespace std; 

bool cmp(int a, int b)
{
  return (a<b);
}

int main()
{
  int num[1000];
  int N;
		
  while( cin >> N)
  {
    for(int i=0; i<N; i++)
      cin >> num[i];
            
    sort(num, num+N, cmp);
            
    for(int i=0; i<N-1; i++)
      cout << num[i] << " " ;
			
    cout << num[N-1] << endl;
  }
		
  return 0;  
}

implementingvirtualinheritance

cpp

#include <iostream>

using namespace std;

class Person
{
    public:
    Person()
    {
        cout<<"Default Constructor of Person() "<<endl;
    }
    Person(int x)
    {
        cout<<"In Person:"<<x<<endl;
    }
};
class Faculty : virtual public Person
{
    public:
    Faculty(int x): Person(x)
    {
        cout<<"In Faculty:"<<x<<endl;
    }
};
class Student :virtual public Person
{
    public:
    Student(int x): Person(x)
    {
        cout<<"In Student:"<<x<<endl;
    }
};
class TA:public Faculty,public Student
{
    public:
    TA(int x):Student(x), Faculty(x)
    {
        cout<<"In TA:"<<x<<endl;
    }
};


class A
{
    int x;
    public:
    /*void setX(int i)
    {
        x=i;
    }*/
    A()
    {
        cout<<"Default fo A"<<endl;
    }
    A(int i)
    {
        x=i;
    }
    void print()
    {
        cout<<"A:"<<x<<endl;
    }
};
class B: virtual public A
{
    public:
    B():A(10)
    {
        //setX(60);
    }

};
class C: virtual public A
{
    public:
    C():A(10)
    {
       // setX(80);
    }
    
};
class D:public B,public C
{
    public:
    D():B(),C(),A(10)
    {}
};

int main()
{
  // TA ta1(30);
  D d;
  d.print();
   return 0;
}

1234567890123456789012345

cpp

#include <iostream>

using namespace std;

int main()
{
    int i;
    cin>>i;
   cout << "Hello World" << endl; 
   
   return 0;
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.