C :: Program Won't Correctly Print Proper Totals On Screen

Oct 10, 2014

Why this program won't correctly print the proper totals on screen? See my code and the included screenshot.

Code:
#include <stdio.h>
int main(void) {
int total, first, second;
printf("Enter 2 numbers:

[Code] .....

View 4 Replies


ADVERTISEMENT

C :: Program To Print All Of Prime Numbers To Screen

May 29, 2013

I'm trying to write a program that prints all of the prime numbers to the screen. I'm getting angry because it only prints EVERY number. I think it has something to do with the bool change not being able to leave the for-loop but how to fix it.

Code:
#import <stdio.h>
#include <stdbool.h>
int main(void){
printf("
The Primes Are: 1");

[Code] ....

View 3 Replies View Related

C/C++ :: Program That Read A Number From Keyboard And Print Separated Digits To Screen

Feb 18, 2015

Basically this is what i need to do. Write a program that reads a number from the keyboard, separates it into its individual digits and prints the digits to screen, each on its own line followed by the same number of stars as itself.

For example, if the number is 2339 the program should print

9 *********
3 ***
3 ***
2 **

So far i have managed to separate the number and have them on different lines, but how to implement the stars onto each line with the number!

My code so far:

int main() {
int n;
printf("number? ");
scanf("%d", &n);
while (n > 0) {
printf("
%d

[Code]...

View 4 Replies View Related

C++ :: Program Not Adding Up Totals

Mar 5, 2014

'm new to programing and I'm trying to get this program to add up a price of coffee to the add on extras such as cinnamon, etc. But once the program runs it doesn't add up the coffee price with the extras and I've been at it for hours...

Code:

#include <iostream>
#include <cstdlib>
using namespace std;
int main()

[Code] ......

View 6 Replies View Related

C :: Program Fails To Show Totals / Averages

May 17, 2014

The code is supposed to display the total and averages of the data as well, but cuts off due to an error in the code. The code should also:

1)Print checks for all employees, one per page, sorted by lastname. The first check number, 100, is to be read from a company data file (see requirement 4). The border of each check is important and should not be omitted.

2)Convert the net pay to a text string for each check printed.

3)Print a reference code on each check. The reference code is obtained by combining the first letter of the lastname with all the consonants remaining after removing all vowels (a,e,i,o,u).

4)Use the same employee data found in assignment 2. Use the following company data, obtained from a text file,

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

[code]....

And here's where the program stops. URL.....

Output I'm expecting: Program to display totals and averages (worked before I turned everything into an array), now exits with error before totals/averages are displayed. Program also writes up a report.txt file that also writes this information into it, as well as using a quicksort to organize the names alphabetically, and print paychecks (all of the #BORDER, #HEADER1-8, #STUB, etc). In that check a reference code is also generated (teacher gave us code, we just had to modify for our final program as seen here)

Flow of the program: Print headings to label all of the input data we will enter soon under the categories as listed in the heading. Initialize all of our totals (in our array) to value of 0. These will be added in a loop "AddAccumulators" which takes our value for the hours, payrate, and taxes from each employee array structure and adds it to the total array. Program will write this information into the report.txt file with the HEADER line for totals, and should be displaying it in that picture. (Same for averages). After all of the data is calculated, the Reference code, Totals, Averages, and individual employee data is taken and put into printing out a Check Header and Stub.

View 10 Replies View Related

Visual C++ :: Program Fails To Show Totals / Averages

May 17, 2014

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

[Code]....

I know it has to do with the array, and I've tried over and over again to fix my issue and nothing has worked thus far.

View 3 Replies View Related

Visual C++ :: Program To Calculate Sales Totals For A General Store - While Loops

Jan 25, 2013

I need coding this project using while loops and cout/cin.. It is suppose to be one while loop for the whole thing and inside of the first while loop is the second while loop for each sale separately.

You have been asked to write a program to calculate sales totals for a general store. Your program will not know how many products each customer will buy, so your program will have to repeat the process until the last product has been entered (use -1 for Product ID to end each sale). After each sale your program must ask if you want to do another sale (Y - continue, N - end program).

At the beginning of the day, the cash drawer has $500 in it. At the end of the program you must display how much money is in the drawer after handling all your sales transactions.

Input
Your program must take the following input:
- Product ID Number (int)
- Quantity for each item purchased (int)
- Cash Received at the end of the sale

Use the following dataset to determine the price and taxability for each item.

First Sale:
Product ID Price Quantity Taxable
101 $65.00 2 Yes
102 $12.50 1 No
103 $24.50 5 No
104 $38.75 4 Yes
105 $17.80 6 Yes
106 $16.50 2 No
107 $42.85 8 Yes
108 $32.99 2 Yes
109 $28.75 1 Yes
110 $51.55 1 No

Second Sale:
Product ID Price Quantity Taxable
102 $12.50 1 No
103 $24.50 1 No
106 $16.50 1 No
107 $42.85 1 Yes
108 $32.99 1 Yes
109 $28.75 1 Yes

Third Sale:
Product ID Price Quantity Taxable
106 $16.50 4 No
107 $42.85 3 Yes
108 $32.99 1 Yes
109 $28.75 5 Yes
110 $51.55 2 No

Calculating Tax
For those items that are taxable, assume a 7.5% sales tax. Be sure to keep a running total of tax for the each sale.

Getting Started
You must use the starter file provided with this assignment.
What to turn in:
- A copy of your source code
- A printout of your program's output

View 2 Replies View Related

C :: How To Get Sum Of Areas And Print On Screen

Mar 19, 2014

So i am struggling for days to get this done and all i need is to get the sum of the areas and get them printed on the screen my code is this:

Code:

#include<stdio.h>
#include <stdlib.h>
#include<conio.h> //Not needed in Dev C++//
#define PI 3.1415
float Area_of_Rectangular(float length,float width);
float Area_of_Circle(float radius);
int main()

[Code]...

View 7 Replies View Related

C :: Program Come Out Without Proper Execution

Jul 11, 2013

the following code doesn't execute properly( After the second entry the program comes out)!!

Code:

#include<stdio.h>
void linkfloat();
int main(){
struct book {
char name;
float price;
int page;
};

[code]....

View 8 Replies View Related

C :: Print The Inverse Number On Screen

Dec 25, 2014

Print the inverse number. Ex: 2178*4=8712

Write down a program which can satisfy the prerequisite and print out the screen.

The answer is:

Code:
void inverse2 ()
{
int i,j;
for (i=1000;i<=9999;i++)
for (j=1;j<=9;j++)
if (i*j==inverse (i))
printf("%5d%2d",i,j);
}

I can't understand the double for loop.

for (i=1000;i<=9999;i++)
for (j=1;j<=9;j++)

And The meaning for

i*j==inverse (i)

View 2 Replies View Related

C :: Printf Doesn't Print On Screen

May 23, 2013

This code runs. However, when I run it, the text from printf doesn't appear until after I type in the two numbers.

I use Wascana, will it run correctly on other compilers?

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
fflush(stdout);

[Code].....

And this is how it turns out on the screen:

Code:

6
3

What size is the die:

how many dice to roll:

Numbers are 3d6
Rolling die no.1...
RolledDie: 4 DieTotal: 4
Rolling die no.2...
RolledDie: 5 DieTotal: 9
Rolling die no.3...
RolledDie: 5 DieTotal: 14

The total is: 14

View 4 Replies View Related

C++ :: Recursion - How To Print To The Screen Value Of N After It Has Been Multiplied

Mar 20, 2013

How to print to the screen the value of n after it has been multiplied.

For example: if I use cout << "n: " << n << " power: " << power << "
"; I

can see the variable "power" decrementing by 1, but I don't see the variable "n" incrementing with its new value after it has been multiplied by n * n.

#include <iostream>
using namespace std;
typedef unsigned short int USHORT;
typedef unsigned long int ULONG;

ULONG Getpower(USHORT n, USHORT power);

[Code] .....

View 2 Replies View Related

C++ :: Check If A Number Is Odd Or Even And Print It To The Screen

Mar 8, 2013

My objective is to check to see if a number is odd or even and print it to the screen just to make sure its working correctly.

The data file contains:
138
402 2 485
9
43
98 805
58
421
948 7 97
48
67
35
42
948
579 39 12
700 20 500 210
98

I can get the numbers to print fine using:

fstream infile1(argv[1]);
if(!infile1.is_open())
cout << "Could not open file";
else {
char listNum;
while(infile1.get(listNum))
cout << listNum;
}

However, when I check for odd or even numbers it will check each and every number.

printed like this (partial list):
1 is odd 3 is odd 8 is even
9 is odd

But it should print:
138 is even
9 is odd

I tried using getline, but it keeps giving me the errors:
invalid conversion from 'void*' to 'char**'
invalid conversion from 'char' to 'size_t*'
too few arguments to function 'ssize_t getline(char**, size_t*, FILE*)'

Here is the getline code, what am I doing wrong? I have tried switching things around, adding things. Just nothing works.

ifstream infile1(argv[1]);
if(!infile1.is_open())
cout << "Could not open file";
else {
char listNum;
getline(infile1, listNum);
cout << listNum;
}

View 2 Replies View Related

C++ :: Store And Print String On Screen

Sep 20, 2013

Given this sentence as an input: "Hello my name and "John" (with its spaces and capital letters), print it on the screen .. NB the phrase must be entered from the keyboard all at once ... you can do this in C / C + +?

View 3 Replies View Related

C/C++ :: How To Print Results On Screen Without Using Printf

Jun 26, 2013

how to print the result on screen without using printf in C...?

View 6 Replies View Related

C++ :: Make Output Print Out To Screen In Reverse?

May 26, 2013

How can I make the output print out to the screen in reverse?

Code: #include <iostream>
#include <iomanip>
using namespace std;
int getnum();
void Fibonacci(int n);

[Code].....

View 7 Replies View Related

C :: Any Way To Read Entire File And Print It On Screen

Feb 26, 2013

is there anyway to read an entire file and print in on screen? file consists of strings and integers!

View 7 Replies View Related

Visual C++ :: How To Print Mathematical Series On Screen

Nov 24, 2013

How do I print a mathematical series such as

1 + 2/2! - 3/3! + ...... n/n! //n is read from user

Not only we need to print the series on the screen but at the same time find the sum using simple loops.

View 1 Replies View Related

C :: Return Errno From Open Function And Print It To Screen

Mar 22, 2013

i am programming Cli/Ser ,so part of the program is to open file to download it from client side,but i want to return the global value Errorno to print it to screen , and how to use strerror() func ??? i write this "This is part of server code" :

Code:

fd= open("abc.txt",O_RDONLY);
//error handilng in open file
if(fd<0)
{

[Code].....

View 3 Replies View Related

C/C++ :: Passing Two Dimensional Array To Function And Print To Screen?

Apr 4, 2015

This seems simple enough but I'm missing something here to make this code work.What I'm trying to do is print the contents of the two dimensional array in 25 rows and 4 columns. I experimented with something similar to this code when I initialized the array with numbers.

#include <iostream>
#include <iomanip>
#include <cmath>

[Code].....

View 1 Replies View Related

C/C++ :: Passing Two Dimensional Array To Function And Print To Screen

Apr 4, 2015

I'm getting garbage. I tried including the name of the array in the cin object but I got an error message that says "no match for operator '>>'. When I take the name of the array out, the program compiles but I get garbage. Program is suppose to reads data from a file of 25 students and calculates test scores and class grade average output each student's name score, letter grade and grade average. I would be happy at this point if I could just print out something that wasn't garbage.

Here is the code.

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <fstream>
using namespace std;
//const
const int Array_Row = 25;
const int Array_Col = 4;

[Code] ......

View 1 Replies View Related

C++ :: Search By Word In Text File And Print Out Whole Line On Screen

Apr 7, 2013

I have a text file where in each line is 3 words and 2 int type numbers. I'm doing search by word and I want to print out to the screen the whole line where that word was found (the words is repeated in some lines). My search looks like this:

Code:
#include<iostream>
#include<string>
#include<fstream>
#include<stdlib.h>
#include <vector>
using namespace std;
int main(){
vector <string> words;
string str, paieska;

[Code] .....

How to print line(s) where I found that word?

View 9 Replies View Related

C++ :: Print Custom Area Of Screen - Save As Image File

Sep 9, 2014

I am trying to automatically(periodically) print screen a custom area of the screen, save it as an image file (the image will have the same format always), and then use OCR to get the text in the image as usable string variables. Is this doable? I was looking into tesseract OCR but I find it a bit unclear.

View 10 Replies View Related

C++ :: Convert List Of Binary Numbers From A File Into Decimal And Print To Screen

Sep 23, 2014

I am trying to make a program that will convert a list of binary numbers from a file into decimal and print the decimal to the screen. I have no problem doing the conversion, the problem comes up when our teacher wants the input file in a format as such:

3
10110101
11111111
10101010

The first number is supposed to tell the program how many different 8bit strings it is going to have to convert, and then the following lines are those binary numbers.

I am not very experienced with file inputs, and I know how to open files and read lines in.. The problem is, how to say "ok the first line says 3, so now I have to convert the next 3 lines" . I am assuming it is just a simple loop that I am missing....

View 4 Replies View Related

C++ :: GPA - Program Not Averaging Correctly?

Feb 7, 2015

My program isnt averaging correctly.

#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;

struct nameGPA {

[Code] .....

View 4 Replies View Related

C++ :: Program Is Not Calculating Sums Correctly?

Jun 20, 2014

I am getting this weird error when calculating sums. Here is what my program does: it generates two random numbers and then randomly puts either an addition or subtraction sign between the two and then I am asked to enter what the correct answer for that question is. But on some of the subtraction questions when I give the answer it says I got it wrong after which the program shows the right answer. What's confusing is that the answer the computer calculates is the same that I entered. Anyways the complete program and a screenshot of the console window which shows the error are below. The function in question here is decAddSub at line 54. The error is shown in the first sum in the output window. It doesn't affect addition problems and only affects some of the subtraction problems.

#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<random>

[Code].....

View 2 Replies View Related







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