run time calculator c++ code example

Example 1: run time calculator c++

#include <iostream>
#include <fstream>
#include "header.h"
#include <queue>
#include <bitset>
using namespace std;


bool checkInputFile(ifstream &input) { //checking if the file is found and opened or not.

	if (!input) {
		return 0; //returning 'false'.
	}
	else {
		cout << "Input file has found !" << endl; //if the target file has been opened , prints a success message.
		return 1; //returning 'true'.
	}
}


bool isEmpty(string s) {

	if (s.size() == NULL) { //if there is no element in the given file , information message will be printed and function will return 'true'.
	  	cout << "Input file is empty." << endl;
		return true;
	}
	else {
		cout << "\nContent of the input file : " << s; //if file isn't empty , information about the file will be printed and function will return 'false'.
		return false;
	}
}

Example 2: run time calculator c++

cout<<"Enter a string to generate a password from it "<<endl;
   cin>>password;
    cout<<endl;

Example 3: run time calculator c++

int x  ;
int d ;
if(h%x == 0){
cout<< d ;}
else
cout<< x ;

Example 4: run time calculator c++

public static LinkedList fnA(int[] arrayA, int[] arrayB) {
LinkedList<Integer> result = new LinkedList<Integer>();
for (int i=0; i<arrayA.length; i++) {
if (!binarySearch(arrayB, arrayA[i]))
result.add(arrayA[i]);
}
for (int i=0; i<arrayB.length; i++) {
if (!binarySearch(arrayA, arrayB[i]))
result.add(arrayB[i]);
}
return result;
}

Example 5: run time calculator c++

print "number between 5-10'

Tags:

Cpp Example