// V stands for OR(disjunction),
//^ stands for AND(conjuction),
//' stand for NOT(negation),
//--> stands for NOT(A) OR B (implication)
//Evaluate expression
// (A V B) --> (B' --> A)
// !(A || B) || (B'' || A)
// !(A || B) || (A || B)
#include<iostream>
#include<iomanip>
#include<string>
#include<sstream>
using namespace std;
bool conjuction(bool a, bool b); // a && b
bool disjunction(bool a, bool b); // a || b
bool negation(bool a); // !a
bool implication(bool a, bool b); //!a || b
bool equivalence(bool a, bool b); // (!a || b) && (a ||
!b)
int main()
{
bool x[4] = {0,0,1,1};
bool y[4] = {0,1,0,1};
bool z[4];
// V stands for OR(disjunction),
//^ stands for AND(conjuction),
//' stand for NOT(negation),
//--> stands for NOT(A) OR B (implication)
//Evaluate expression
// (A V B) --> (B' --> A)
// !(A || B) || (B'' || A)
// !(A || B) || (A || B)
cout<<"Truth table\n";
cout<<"| A | B |Result|\n";
cout<<"-----------------------\n";
for(int i=0;i<4;i++)
{
z[i] = disjunction(x[i],y[i]); // (A || B)
z[i] = disjunction(negation(z[i]),z[i]); //!(A || B) || (A ||
B)
cout<<"| ";
if(x[i] == 0)
cout<<"False |";
else
cout<<"True |";
if(y[i] == 0)
cout<<"False |";
else
cout<<"True |";
if(z[i] == 0)
cout<<"False |";
else
cout<<"True |\n";
}
}
bool conjuction(bool a, bool b) // a && b
{
if(a==1 && b==1)
return 1;
return 0;
}
bool disjunction(bool a, bool b) // a || b
{
if(a==0 && b==0)
return 0;
return 1;
}
bool negation(bool a) // !a
{
if(a==1)
return 0;
return 1;
}
bool implication(bool a, bool b) //!a || b
{
if(a==1 && b==0)
return 0;
return 1;
}
bool equivalence(bool a, bool b) // (!a || b) && (a ||
!b)
{
if (a == b)
return 1;
return 0;
}
output:-
Prove:-
c++ please include comments 4. Rewrite the code below including the definitions of the function prototypes...
#include <iostream> #include <cstring> #include <string> #include <istream> using namespace std; //Function prototypes int numVowels(char *str); int numConsonants(char *str); int main() { char string[100]; char inputChoice, choice[2]; int vowelTotal, consonantTotal; //Input a string cout << "Enter a string: " << endl; cin.getline(string, 100); do { //Displays the Menu cout << " (A) Count the number of vowels in the string"<<endl; cout << " (B) Count...
Code in C++ Function Prototypes For the second part of the lab activity, you will be practicing writing function prototypes. Continue working on the same project from part A. First, rewrite the code so that you are using function prototypes for the functions getNumber.getMessage, and repeat. Remember that the prototypes go at the top of the file, followed by main, then the definitions of the three functions at the end. Second, you will be creating a new function (procedure) called...
#include <iostream> #include <cstring> #include <string> #include <istream> using namespace std; //Function prototypes int numVowels(char *str); int numConsonants(char *str); int main() { char string[100]; char inputChoice, choice[2]; int vowelTotal, consonantTotal; //Input a string cout << "Enter a string: " << endl; cin.getline(string, 100); do { //Displays the Menu cout << " (A) Count the number of vowels in the string"<<endl; cout << " (B) Count...
Please rewrite this function using recursive function #include using namespace std; struct Node { char ch; Node* next; }; class LinkedList { Node* head; public: LinkedList(); ~LinkedList(); void add(char ch); bool find(char ch); bool del(char ch); friend std::ostream& operator<<(std::ostream& out, LinkedList& list); }; LinkedList::LinkedList() { head = NULL; } LinkedList::~LinkedList() { Node* cur = head, * tmp; while (cur != NULL) { tmp = cur->next; delete cur; cur = tmp; } } void LinkedList::add(char ch) { Node* cur = head,...
SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! mystring.h: //File: mystring1.h // ================ // Interface file for user-defined String class. #ifndef _MYSTRING_H #define _MYSTRING_H #include<iostream> #include <cstring> // for strlen(), etc. using namespace std; #define MAX_STR_LENGTH 200 class String { public: String(); String(const char s[]); // a conversion constructor void append(const String &str); // Relational operators bool operator ==(const String &str) const; bool operator !=(const String &str) const; bool operator >(const...
Create Functions for the following prototypes. Below is the setup.*program is in c* #include <stdio.h> #include <string.h> #include <stdarg.h> #include <stdlib.h> //#define constant values #define MAX_URL_LENGTH 50 #define TRUE 1 #define FALSE 0 //typedef for the Element struct which constains a c string to store a URL in the BrowserList typedef struct { char szURL[MAX_URL_LENGTH]; } Element; //Typedef for a node in the doubly linked list (has next and previous pointers). typedef struct NodeDL { Element element; struct NodeDL *pNext;...
In C++: Please help me correct this code .... All parts with (FIX ME) #include <algorithm> #include <climits> #include <iostream> #include <string> // atoi #include <time.h> #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ const unsigned int DEFAULT_SIZE = 179; // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() {...
C++ 4. (5 points) Identify the following items in the programming code shown below: a. Function prototype, function heading, function body, and function definitions. b. Function call statements, formal parameters, and actual parameters. C. Value parameters and reference parameters. d. Local variables and global variables. 6. Named constants. #include <iostream> //Line 1 using namespace std; //Line 2 const double NUM = 3.5; //Line 3 int temp; //Line 4 void func(int, doubles, char); //Line 5 int main() int num; double one;...
in c++ please program for this code #include <iostream> #include <fstream> #include <string> #include <cstring> // for string tokenizer and c-style string processing #include <algorithm> // max function #include <stdlib.h> #include <time.h> using namespace std; // Extend the code here as needed class BTNode{ private: int nodeid; int data; int levelNum; BTNode* leftChildPtr; BTNode* rightChildPtr; public: BTNode(){} void setNodeId(int id){ nodeid = id; } int getNodeId(){ return nodeid; } void setData(int d){ data = d; } int getData(){ return data;...
My C++ program is not compiling. Please explain how you fixed with detailed inline comments. I am using Visual Studio 2017. It's a character count program that keeps and displays a count of all the upper, lower case and digits in a .txt file. The requirement is to use classes to implement it. -----------------------------------------------------------------HEADER FILE - Text.h--------------------------------------------------------------------------------------------- /* Header file contains only the class declarations and method prototypes. Comple class definitions will be in the class file.*/ #ifndef TEXT_H #define...