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

P1

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;

int main()
{
 //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// Program: Lab 01
// Author: Matt Trevino
// Date: 9/717
// Course: CSCI/CMPE 2380
// Description: This program will prompt the user for both an input and an
//  output file name.  Afterwards, it will prompt for a target word.  
//  The program opens the file and reads all the words in the file and keeps 
//  track of how many times that word appears.  It writes (appends) the word 
//  and the number to the output file.  It continues this until the user
//  types "exit".
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\


#include<iostream>
#include<fstream>
#include<string>

using namespace std;


//This function opens the output file to append the word and count on a new line
bool WriteWordToFile(string outputFile, string searchWord, int wordCount)
{
    ofstream fout;
    fout.open("outputFile");
    if (fout){
        return true;
    }
    else{
        return false;
    }
}




//This function opens the inputfile and searches for the word.  It returns
//the number of times the word appears.  It assumes that it is case sensitive
//and that there is no punctuation.  Thus, the simple extraction operator can
//be used.
int SearchFile(string inputFile, string searchWord)
{
   ifstream fin;
   string word;
   int counter;
   fin.open("inputFile.txt");
       while(getline(fin, word)){
           if (word == searchWord){
               counter++;
           }
       }
    return counter;
}


//The main function of the program.  This gets the file names and the word to 
//search and then calls the functions.
int main()
{
    string inputFile;
    string outputFile;
    string searchWord;
    int wordCount;
    
    //get input file name
    cout << "Please enter input file name: ";
    cin >> inputFile;
    
    //get output file name
    cout << "Please enter output file name: ";
    cin >> outputFile;
    
    //get word to search
    cout << "What word would you like to search for? ";
    cin >> searchWord;
        
    do
    {    
        //search for word and get count
        wordCount = SearchFile(inputFile, searchWord);
        
        //record the word and count
        WriteWordToFile(outputFile, searchWord, wordCount);
        
        //get word to search
        
    }
    while(searchWord != "exit");
    
    
    return 0;
}

   
   return 0;
}

Compile and Execute C++ Online

cpp

#include <iostream>
#include <functional>
#include <stdio.h>      
#include <math.h>       
#include <string.h>
#include <vector>
#include <stdlib.h>     
using namespace std;

// Generic findMax, with a function object, C++ style.
// Precondition: a.size( ) > 0.
template <typename Object, typename Comparator>
const Object & findMax( const vector<Object> & arr, Comparator isLessThan )
{
    int maxIndex = 0;

    for( int i = 1; i < arr.size( ); ++i )
        if( isLessThan( arr[ maxIndex ], arr[ i]))
            maxIndex = i;
    return arr[ maxIndex ];
}

// Generic findMax, using default ordering.
template <typename Object>
const Object & findMax( const vector<Object> & arr )
{
    return findMax( arr, less<Object>{ } );
}

class Rectangle 
{
    /* 
        going to assume I can just make a rectangle in a 
        0,y2--------x2,y2
          |            |
        0,0--------x2,0 style.
        using distance forumla and stuff could also be used
        but since rectangles are 90 angels all around
        I'll will do it with the assumption that it is a nice rectangle
        and is not rotated in some form, since this would be a general answer
        if there is rotation a small change would work
    */
    private:
        int x1, y1, x2, y2; 
        int getLength (int start, int end)
            {return abs(start-end); }
        int getWidth (int start, int end)
            {return abs(start-end);}
        int Length = getLength(x1,x2);
        int Width = getWidth(y1,y2);
    public:
        void set_cords (int cord1, int cord2, int cord3, int cord4) 
        {
            x1 = cord1, 
            y1 = cord2, 
            x2 = cord3, 
            y2 = cord4;
        }
        void printStuff () 
        {
            printf ("%d \n", x1);
            printf ("%d \n", y1);
            printf ("%d \n", x2);
            printf ("%d \n \n", y2);
            printf ("%d \n", getLength(x1,x2));
            printf ("%d \n \n", getWidth(y1,y2));
            printf ("%d \n", Area());
            printf ("%d \n \n", Perimeter());
            
        }
        int Area() {return getLength(x1,x2)*getWidth(y1,y2);}
        int Perimeter() {return getLength(x1,x2)*2 + getWidth(y1,y2)*2;}
        /* 
        For some reason Length and Width give tons of problems not sure how to fix
        it so just going to use the step use to get the Length and Width  
        int Area(){return Length*Width;}
        int Perimeter() {return Length*2 + Width*2;}
        
        Must be something with PBR and PBV but not sure.
        */
        
        /*  no idea what this is for 
        bool operator( )( const int & lhs, const int & rhs ) const
        { return strcasecmp( lhs.c_str( ), rhs.c_str( ) ) < 0; }
        */       
};

int main () {
    int myints1[] = {0,0,5,3};
    int myints2[] = {0,0,3,9};
    int myints3[] = {0,0,5,25};
    int myints4[] = {0,0,10,13};
    Rectangle Rect1;
    Rectangle Rect2;
    Rectangle Rect3;
    Rectangle Rect4;
    Rect1.set_cords(myints1[0], myints1[1], myints1[2], myints1[3] );
    Rect2.set_cords(myints2[0], myints2[1], myints2[2], myints2[3] );
    Rect3.set_cords(myints3[0], myints3[1], myints3[2], myints3[3] );
    Rect4.set_cords(myints4[0], myints4[1], myints4[2], myints4[3] );
    /*  Can be use to check stuff in more detail if needed  
        Rect1.printStuff();
        Rect2.printStuff();
        Rect3.printStuff();
        Rect4.printStuff();
    */
    int myAreas[] = {Rect1.Area(), Rect2.Area(), Rect3.Area(), Rect4.Area()};
    int myPerimeters[] = {Rect1.Perimeter(), Rect2.Perimeter(), Rect3.Perimeter(), Rect4.Perimeter()};
  
    vector<int> Areas (myAreas, myAreas + sizeof(myAreas) / sizeof(int) );
    vector<int> Perimeters (myPerimeters, myPerimeters + sizeof(myPerimeters) / sizeof(int) );
    /*
    figure 1.25 use a lot of vectors for the max instead of using 
    the arrays.  The question ask for usage of array, but is kind of
    the same thing so, I just did it like so (?)
    Also no idea whatsoever on what 
    template <typename Object, typename Comparator>
    const Object & findMax( const vector<Object> & arr, Comparator isLessThan )
    stuff is about can't understand almost anything of that code portion.
    */
    printf ("%s %d \n", "the max area in these rectangels is: ", findMax(Areas));
    printf ("%s %d \n", "the max primeter in these rectangels is: ", findMax(Perimeters));
    
    /*
    Not Sure if I had to make something else, like point which rectangle is it or
     I have ro give a name to each rectangle and then after finding the one with the
     max area do a for loop to search which rectangle it was that had that area
     or something else, but to do that, it feels like it would require a lot more code
     than what it is asking for, or make the areas into vector of arrays where
     each array has a form {RectName, Area, Perimete} and then do some stuff with this
     but oing so means you would somewhat had to mess with the findMax to make it work
     but findMax feels according to the question feels like we shouldn't mess with.
     So I just print the result of which area and perimeter are the biggest.
    */
    return 0;
}

Enter a beautiful name for your project

cpp

#include <iostream>
#include <windows.h>
using namespace std;

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

tempjsskkaajabHKmabaHIajsgsiskakanabshjaka

cpp

#include <iostream>

using namespace std;

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

Basic. ........ Programing ........of C++

cpp

#include <iostream>

using namespace std;

int main()
{
    clrscr();
   cout <<  Ranjit kumar << endl; 
   
   return 0;
}

RushikeshHaridasRekhaKadam

cpp

//============================================================================
// Name        : DFS_AssignmentNo1.cpp
// Author      : Rushikesh
// Version     :
// Copyright   : @rushikesh
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
#define MAX 100

class LinearArray
{
public:
		long int ACN;
		string FNAME,LNAME;
		int FEES,YEAR;
		void insert();
		void display();
		//void searchbyyear(int year);
		//void searchbyfees(int fee);
};

void LinearArray::insert()
{
	cout<<"\n************************************************************";
	cout<<"\nEnter the Adhar Card No.:";
	cin>>ACN;
	cout<<"\nEnter the first name:";
	cin>>FNAME;
	cout<<"\nEnter the Last name:";
	cin>>LNAME;
	cout<<"\nEnter the fees:";
	cin>>FEES;
	cout<<"\nEnter the Year:";
	cin>>YEAR;
	cout<<"\n************************************************************";
}

void LinearArray::display()
{
	cout<<"\n************************************************************";
	cout<<"\nAdhar card NO.="<<ACN;
	cout<<"\nFirst Name="<<FNAME;
	cout<<"\nLast name="<<LNAME;
	cout<<"\nFees="<<FEES;
	cout<<"\nYear="<<YEAR;
	cout<<"\n************************************************************";
}

int main()
{
	static int STRENGTH=0;
	LinearArray a[30];
	int ch1,n,fee,year,temp=0;
	char ch2;
	do
	{
		cout<<"************************************************************";
		cout<<"\n1.Insert record\n2.Display records\n3.Search records by using Fees\n4.Search by using Year";
		cout<<"\n************************************************************";
		cout<<"\nEnter your choice:";
		cin>>ch1;
		switch(ch1)
		{
			case 1:
					cout<<"\nHow many records you want to insert...?";
					cin>>n;
					temp+=n;
					while(STRENGTH<temp)
					{
						a[STRENGTH].insert();
						STRENGTH++;
					}
					break;
			case 2:
					for(int i=0;i<STRENGTH;i++)
					{
						a[i].display();
					}
					break;
			case 3:
					cout<<"\nEnter the fees:";
					cin>>fee;
					cout<<"\nDetails of the Students whose Fees are "<<fee<<" and more than "<<fee<<":";
					for(int i=0;i<STRENGTH;i++)
					{
						if(a[i].FEES>=fee)
						{
							cout<<"\nAdhar card NO.="<<a[i].ACN;
							cout<<"\nFirst Name="<<a[i].FNAME;
							cout<<"\nLast name="<<a[i].LNAME;
							cout<<"\nYear="<<a[i].YEAR;
						}
					}
					break;
			case 4:
					cout<<"\nEnter the year:";
					cin>>year;
					cout<<"\nDetails of the Students whose year is "<<year;
					for(int i=0;i<STRENGTH;i++)
					{
						if(a[i].YEAR>=year)
						{
							cout<<"\n************************************************************";
							cout<<"Adhar card NO.="<<a[i].ACN;
							cout<<"First Name="<<a[i].FNAME;
							cout<<"Last name="<<a[i].LNAME;
							cout<<"Fees="<<a[i].FEES;
							cout<<"\n************************************************************";
						}
					}
					break;
			default:
					cout<<"\nInvalid Choice!!!";
					break;
		}
		cout<<"\nDo you want to continue...?(Y/N):";
		cin>>ch2;
	}while(ch2=='Y'||ch2=='y');
	return 0;
}

Advertisements
Loading...

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