C++ :: Program That Takes Sum Of Products And Generates Sum Of Minterms

Nov 28, 2013

Write a C/C++ program that reads a boolean expression in sum-of-products form and generates the sum-of-minterms form (canonical form). Use single letter to represent variables. The following symbols will be used to represent operators: NOT: ~, AND: *, OR: +. Other operators won't be used.

Examples of execution:
number of variables: 2
SOP expression: ~A+B
output: ~A*~B + ~A*B + A*B

number of variables: 3
SOP expression: x*y*z + ~x*~y + y*~z
output: x*y*z + ~x*~y*z + ~x*~y*~z + x*y*~z + ~x*y*~z

View 3 Replies


ADVERTISEMENT

C++ :: Infinite Loop When Program Generates New Bracket

Feb 14, 2014

I am getting an infinite loop when my program generates a new bracket

#include <iostream>
#include <string>
#include <stdlib.h>
#include <numeric>
#include <fstream>
#include <vector>
using namespace std;
const int MAXTEAMS = 20;
const char* c;

[Code] ....

View 2 Replies View Related

C++ :: Program That Generates 5 Non Duplicate Numbers Between 1 And 20 By Using Arrays

Nov 4, 2014

program that generates 5 non duplicate numbers that is between 1 and 20 by using arrays. Here is my code and i cant compile it.

#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <iomanip>
using namespace std;
int main() {
srand(time(NULL));

[Code]...

View 3 Replies View Related

C++ :: Program That Takes Several Numbers Into Array Into A Function

Nov 25, 2014

I have to make a program that takes several numbers into an array into a function, and send them back into the main function multiplied by 1.13. This is what I have so far:

#include <iostream>
using namespace std;
void connell(int&n[20])
main() {
int num[20];

[Code] ...

I do not know how to get numbers from an array from a main program to a function.

View 2 Replies View Related

C++ :: Program That Takes Two Complex Number And Return Their Sum?

Oct 25, 2013

you have been tasked to write a program that takes two complex number and return their sum.However the + operator will not worl with complex numbers and you figure you need to verload the + and the assignment opeartor=.Ypu have come across the program [URL]

implement it and the client code to see it rune for the following complex numbers:

c1=3.0-4i,c2=8+4i

i have 3 files,driver.cpp,Complexnumber.cpp and complexNumber.h

complex.cpp is as follows

#include <iostream>
using namespace std;
class ComplexNumber {
private:
double real;
double image;

[code]....

View 4 Replies View Related

C :: Make Program That Takes Number Input From Tuser?

Jul 27, 2013

I have to make a program that takes a number input from the user and prints the corresponding fibonacci sequence number. For example, for the input of 3, it should print 2 since the third term in the fibonacci sequence is 2.

I am not sure how to do this so for my attempt, I used the formula found in this website. A Formula for the nth Fibonacci number

Here is the program so far. It doesn't produce the correct output.

Code:

#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
#include "math.h"

[Code]....

View 11 Replies View Related

C :: Program That Takes A Large Text File As Input

Nov 7, 2014

I am writing a spell checker for a exercise for a class I am taking online. I have to load a huge text file of 143092 words into a hash table.

The program segfaults on word number 63197. Is there a way to debug this in gdb without having to step threw the function 63197 times.

View 3 Replies View Related

C++ :: Program Which Takes Date And Time Input From The User

Jan 20, 2013

I am writing a C++ program which takes date & time input from the user. This is then parsed into a struct such as:

struct time
{
short year;
short month;
short day;
short hour;
short min;
};

My question is: how can I convert such a struct into a time_t object, which is an unsigned long giving the time as the number of seconds elapsed since the epoch Jan 1st 1970, 00:00, as set out in time.h.

I am wondering if this can be achieved using the standard library, or whether I just need to write a function to perform the appropriate arithmetic.

View 2 Replies View Related

C++ :: Program Which Takes Input From User And Write It To A File

Jan 15, 2013

A program which takes input from user and write it to a file then it reads data from that file then it should search for specific data such as email adresses or url etc.

View 1 Replies View Related

C :: Program That Takes Multiple Integers From User And Finds Minimum Value

Jun 11, 2014

Write a C program that takes multiple integers from the user and finds the minimum value. The numbers entered by the user are positive integers. When the user is done entering all the numbers, the user enters the sentinel value of -1.

This is a sample output. Notice how the program prints a counter (1, 2, 3, ) for user keep track of how many numbers were entered so far. Include this feature in your program.

I have tried different ways to get the result from while loops, do while, and if-else statements. We have not done any max/min problem in class and the book was kind of vague. We have not learned arrays yet in class and I can't figure a way to compare the integers the user inputs as it is an infinite(from what I am reading) amount aloud. The problem I am seeing is the loop works and stops with the sentinel value but the INT_MIN is using the sentinel value. I also have not addressed the input of negative numbers yet with the first program I wrote, maybe one of my problems.

Code:
/*File:HW2Q3.c,
A C program that takes multiple integers from the user and finds the minimum value. The numbers entered by the user are positive integers. When the user is done entering all the numbers, the user enters the sentinel value of -1.*/
/*header files*/
#include<stdio.h>
#include<limits.h>
/*****start program*****/
int main() {

[Code] ....

I have also tried this way as well, min value still comes back as -1 the sentinel value, and the else statement is being ignored. I am sure it is something silly but I am lost and confused at this point.

Code:
/*File:HW2Q3.c,
A C program that takes multiple integers from the user and finds the minimum value. The numbers entered by the user are positive integers. When the user is done entering all the numbers, the user enters the sentinel value of -1.*/
/*header files*/
#include<stdio.h>
#include<limits.h>

[Code] ....

View 13 Replies View Related

C/C++ :: Program Takes Integer Input And Displays Each Digit On New Line From Right To Left

Jan 23, 2015

I'm trying to create a program that takes an integer input and displays each digit on a new line from right to left.

An example of this would be:

Enter an integer: 657
Digit (1): 7
Digit (2): 5
Digit (3): 6

So far I have this:

#include <stdio.h>
#include <math.h>
int main() {
int i, input, output;
printf("Enter an integer: ");
scanf("%d", &input);
if(input == 0)
printf("Digit (1): 0");

[Code] ....

It works perfectly fine, but I just learned that I am not allowed to use the #include <math.h> so I have to take out floor, log, and pow.

I'm pretty sure I have to do some sort of while or for loop to get the results, but how to do it.

View 6 Replies View Related

C/C++ :: Unable To Create A Program That Takes Command Line Arguments And Prints Last One

Jan 18, 2015

I'm just getting back into the swing of things after a long time of not programming. I'm trying to create a program which takes in command line arguments and prints the last one. My code is as follows:

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
string x;
vector<string> arguments;

[Code]...

And the error message I receive, a simple but frustrating one, is as follows:

Enter arguments, enter STOP to stop: Segmentation fault...

View 1 Replies View Related

C :: Create Program That Takes In Information And Formats It Into 3 Columns - Float Variable Not Working

Dec 12, 2013

Here your supposed to create a program that takes in information and formats it into three columns.

I can't seem to use the float variable unitprice with decimal places here for, if I try to use %.1f and type in an input, the program seems to skip over the second scanf function, not allowing me to put input into the third scanf function as the program runs before I can.

I can use %f on its own and it works but this creates too many zeroes(and you're supposed to set the currency limit to $99999.99).

Code:
#include <stdio.h>
int main(void) {
int itemno, month, year, day;
float unitprice;

[Code]....

So the output should look like three columns. It's just the float that is the issue here....

View 5 Replies View Related

C++ :: Program That Takes Baseball Players Statistics And Display Averages - Function Division

Oct 10, 2013

I was required to write a program that takes a baseball players statistics and displays there averages. I was required to make 3 function in the file to perform this tasks. my problem I am having a division problem in the SLG function. My compiler does not require the system ("PAUSE"); command.

OUTPUT
The player's batting average is: 0.347
The player's on-base percentage is: 0.375
The player's slugging percentage is:
(test)AB = 101
(test)Tot Base = 58
0.000

Code:
/* Batting Average Program
file: batavg1CPP.cpp
Glossary of abbreviations:
BA = batting average
PA = plate appearances
H = hits
BB = bases on balls (walks)

[Code] ....

View 3 Replies View Related

C :: Input Matrices Dimensions - Calculate Elements Of Products

Nov 14, 2013

This is my code and it's not giving me the right output

Code:
#include <stdio.h>
int main() {
int dim;
int i, row, col;
// inputting matrices dimensions
int M0, M1, M2;

[Code] ....

The output should give me this:
Input 2
Correct Output 2 5 4 10

View 10 Replies View Related

C :: Create A Structure To Store Information About Products For Sale

Apr 29, 2013

I am using Dev C++ compiler on Windows 7 and was programming a piece of code that is supposed to do the following -

Create a structure to store information about products for sale in a store. It should store information about the product name, the price, and the product number and then create an array of products called Inventory. Add five products to your inventory.

But for some reason, which is unknown to me, I always seem to get a compiler error. And this is what i have so far -

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct product{
char name[30];
int product_number;
double price;

[Code] ....

View 4 Replies View Related

C++ ::  Tree Data Structure To Represent Category And Subcategory Of Products

Jan 15, 2015

Given a product category and sub­category representation:

a. Come up with a tree data structure to minimally (in terms of storage) represent this
b. Write a program to convert the given representation (shown in example below) to this
c. Write a function to output the tree structure in a nice human readable format

Note:
a. There can be any number of levels of depth
b. Rows may be repeated in input, but need to feature only once in the final tree.

Example category list (read this input from a file):

everything else|office supplies
electronics|video games
electronics|video games|accessories
electronics|video games|accessories|headsets
electronics|video games|accessories|flight controls
electronics|video games|accessories|joysticks

View 5 Replies View Related

C++ :: Functions Without Parameters - Compute And Print Total Number Of Products For Company

Mar 27, 2013

Summary: 6 companies have a product in 5 different warehouses. Each company is identified by a positive ID number and each warehouse is identified by a number (1 for the first, 2 for the second,…)

Object: the object of this assignment is to write a C++ program which asks the user to enter a company ID number, and the number of products in each of the warehouses. It then computes and prints the total number of products for that company

If the total number of product is less than 100, it prints the message “place a new order”

Input: for each company, its ID, and the number of products in each warehouse with appropriate prompt messages.
Example: Enter company ID number: 101
Enter number of products in warehouse #1:30
Enter number of products in warehouse #2:60
Enter number of products in warehouse #3:0
Enter number of products in warehouse #4:5
Enter number of products in warehouse #5:27
The total for company 101 is:122

Output: for each company, the total number of product, and the message “place a new order” if the total number of product is less than 100.

Method:
1. Define global variable, int total_prod to hold the total number of products for a company
2. define the function void compute_total() that uses a loop to read the number of the products in all warehouses for one company, computer the total number of products and store it into the global variable total_prod.
3. Define the function void new_order() that determines if a new order need to be placed as follows: if the total number of products (in the global variable total_prod) is less than 100, it prints the message “place a new order”
4. Your function main does the following in a loop:
- read a company ID number
- call function compute_total() to read the number of the product in all warehouses for that company, and to compute their sum
- print the total number of the product for that company with an appropriate message
- call the function new_order() to determine if a new order need to be placed.

View 17 Replies View Related

C++ :: Random Generator Generates Same Numbers Each Time?

Apr 24, 2014

The user thinks of a number from 0 to 100 and the program tries to guess it. The problem is, I'm new to random numbers and use a function to generate them that isn't my own. It generates the same numbers each time the program runs, here are screen shots:

Run 1: [URL] .....

Run 2: [URL] .....

I read something about seeding or something, if I need it, must don't give me the answer. If you have the liberty of time explain more to me about the random business.

Here is my code:

#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <unistd.h>
#include <string>
#include <ctime>
using namespace std;
int rand_lim(int limit) {

[Code] ....

View 4 Replies View Related

C++ :: Partly Recompilation Generates Invalid Address Fault?

Jun 1, 2013

I'm making an x86 emulator with C++ (currently 8086/80186 with some little unfound errors). When I'm compiling all the files (deleting all *.o files and running make), the emulator runs fine (still some errors, but it runs). When I run make, just having one file adjusted, the emulator (JPCSP, a PSP emulator) gives me an invalid opcode/address fault. The emulator does use some pointers at different places though (mostly dynamic memory and optimization), can this be the cause? Causing addressing errors with partial recompilation using make?

View 1 Replies View Related

C/C++ :: Function That Generates A Random String Of Uppercase Letters

Apr 19, 2014

I need to write a C function that generates a random character array (i.e. string) of uppercase letters - getchar and putchar are the only IO functions that I can use. Below is what I have already - I am iterating for as many times as I am required to, and am modulating rand() by 25, (total letters in the alphabet). I'm trying to see how to get the random letter from the % 25, and also how to do this without toupper() [not sure if I can use that function].

void getRandomStr()){
char str[40];
for (int i = 0; i < 40; i++){
char c = rand() % 25);
str[i] = toupper(c);
}}

View 5 Replies View Related

C++ :: Generates Random Addition For Subtraction Depending On User Choice

Feb 17, 2012

Below is a program that generates random Addition for Subtraction problems depending on the user's choice. The user is prompted to input an answer and then it keeps your score. If you want to quit you just press zero.

Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iomanip>
#include <string>
using namespace std;
int menu();
bool addition(int &reward); // function to return truth values

[Code] ....

View 14 Replies View Related

C++ :: Function That Takes Int As Argument And Doubles It?

Jan 7, 2014

Write a c++ function that takes int as an argument and doubles it.the function does not return a value.

View 5 Replies View Related

C++ :: Pow - No Overloaded Function Takes 1 Arguments

Oct 4, 2013

I keep getting this error in my code. I believe it is because to use pow(x,y) both x and y have to be double, but how do i put that into my formula under calculations?

#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
int main() {
// Declaration section: Declaring all variables.

[Code] ....

View 4 Replies View Related

C :: How To Call A Function That Takes A STRUCT Parameter

Feb 23, 2015

I just want to call the function : outputboo(), but I dont know how

Code: /*Enthusiastic
Pessimism
desensitize
uniqueness
*/
#include <stdio.h>
#include <string.h>
struct Books{
char title[50];
char author[50];

[Code]...

View 2 Replies View Related

C :: Addition And Subtraction Calculator That Takes Input?

Feb 23, 2013

I'm writing an addition and subtraction calculator that takes input as: 5+6-3+2. You should be able to add or sub as many numbers as you want. I want the while loop to stop when the user hits enter. I put the getchar() function to catch the and break the loop but it is also swallowing the '-' sign, which I want to use to subtract and is instead adding the numbers with "sum+=number". How can I get around that?

Code:

#include <stdio.h>
int main(int argc, char *argv[]){
int number, sum = 0;

[Code]....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved