C :: Multiple Functions Within A Program

Jan 22, 2013

I am getting an error on lines 31 and 36 about an expected identifier on my program that computes area and circumference. Is something wrong with my external functions outside of main?

Code:
#include <stdio.h>
#define PI 3.14159

double area;
double circum;

double find_circum (double radius);
double find_area (double radius);

[Code] ....

View 2 Replies


ADVERTISEMENT

C++ :: Executing Multiple Functions In Program

Mar 24, 2013

We have been assigned to create a program that uses multiple functions. The professor has given us code for two of the functions, one to open a file and then another one to read the files contents and output them. I have put these into my program but they will not execute. The program does run, but the functions themselves are not executing. I have practiced with other functions that contain no parameters and those run fine, but the functions she gave us have multiple parameters.

The code I have so far is below:

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
void PrintFile (string FileName, ifstream& inFile);
int main () {
ifstream inFile;
string fileName;

[Code] .....

View 1 Replies View Related

C/C++ :: Program Using Multiple Functions That Will Calculate Salary?

Feb 21, 2014

I already wrote a program that will calculate the gross pay for a set of employees.

I want modify the code by adding multiple functions.

I want to create a separate function whenever possible to break up the program.

For example, I would like have a function for obtaining the hours from the user, another function for calculating overtime hours, another for calculating gross pay and another function for producing the output.

#include <stdio.h>
#include <stdlib.h>
#define STD_HOURS 40.0
#define OT hour>STD_HOURS
#define SIZE 5
int main() {
int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615}; /* employee ID */

[code]....

View 2 Replies View Related

C++ :: Program Using Switch Statements To Pass Multiple Functions

Oct 1, 2014

I am returning area from areaCircle(), but do not know how to print it in main. I know this program has lots of errors, two cases that I have listed.

Not sure how to properly list multiple function calls in a switch statement, and how to print one's return from main.

int main() {
char choice;
double area;
showMenu(choice);
switch (choice) // If input is C, use getRadius, areaCircle and count, then print the are
{
case 'C': void getRadius(),double areaCircle(), void count(bool display = false);

[Code]...

View 5 Replies View Related

C :: Void Functions With If Else Construct Not Printing Multiple Lines

Apr 12, 2014

This code i made is a cent converter from 5 to 95 cents. The problem i'm receiving is when the 'cents' function is sent back to the 'main' function it only prints one line. It seems to just print the first if construct that complies with the statement. Is there anyway i can have this function print multiple cent values? For example if 60 cents was entered it would only print '50c', and i want it to print '50c' and '10c' instead.

Code:

#include <stdio.h>
int x;
void check(int x)
{
if( x < 5)
printf("Less then 5 cannot be calculated
");
else if(x > 95)

[code]....

View 3 Replies View Related

C++ :: Globally Declared Arrays Accessed By Multiple Functions

Mar 15, 2013

I currently have globally declared arrays, which are accessed by multiple functions. I want to turn the program so that the arrays are no longer globally declared, but are passed to functions by reference.

I have one problem with passing the arrays: I found that, through debugging, I HAVE TO resize the array when I pass it by reference. For instance, I was using int a[10] when it was globally declared, when it is passed by reference with size 10, it does not work, instead it should be higher than 10 (certain number). Why is this happening? I do not get it...

View 6 Replies View Related

C++ :: Create A Program For Multiple Windows

Aug 18, 2013

i am trying to create a program for multiple windows. Here is my code

#include<Windows.h>
// Store handles to the main window and application instance globally.
HWND ghFirstWnd =0;
HWND ghSecondWnd=0;
HWND ghThirdWnd=0;
HINSTANCE ghAppInst=0;

[Code]...

problem is when i try to execute the code it just say create window1- failed!!

View 1 Replies View Related

C :: Blackjack Program - Multiple Choices In Switch

Dec 6, 2014

I'm writing a Blackjack program where the user can choose to Hit(H) or Stand (S). I would like them to be able to use upper or lower case letter for this. My code doesn't seem to work right for my Stands.

Code:
char choice;
do {
choice = 0;
while (choice < 1) {
printf("

[Code] ....

View 3 Replies View Related

C++ :: Program That Will Give Multiple Calculation Results

Apr 4, 2013

I need to write a program that will give me multiple calculation results.

#include <iostream>
using namespace std;
int main () {
int x = 8;
int y = 7;

[Code] ....

It only calculates the last two numbers: 1 and 0, so therefor it gives me 1.

But i need to calculate x and y each time they are smaller(incremented) by one digit.

Please note that the int calculation formula needs to stay.

View 2 Replies View Related

C++ :: Reading Multiple Text Files In Program

May 31, 2013

I want to know how to read multiple text files in this program... I have 5 text files(order1,order2,...order5).

#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<windows.h>
using namespace std;
class{

[Code] ....

View 3 Replies View Related

C++ :: Functions - Declaring First And Defining Later In Program

Apr 6, 2013

I am looking at functions still and can't see the point in declaring the function at the top of the program, and then defining later i.e.

Code:
#include <iostream>
int add (int x, int y) {
return x + y;

[Code] .....

I obviously don't have much real world experience with this and am interested to see where declaring and defining later would be useful and/or beneficial.

View 14 Replies View Related

C :: Remove The Functions In A Program By Pre-processing

Jun 16, 2013

Is there a program that can remove the functions in a program by preprocessing

Code:

#include<stdio.h>
int is_even(int number);
int main(void)
{
if(is_even(number))
{
printf("%d is even", number);
}
}

[Code]...

To something like

Code:

#include<stdio.h>
int is_even(int number);
int main(void)
{
if( number%2 ==0 )
{
printf("%d is even", number);
}
}

I use the "-E" option when compiling with gcc on linux but its output still contains funcitons. Is there a preprocessing program that can remove functions from a program?

View 6 Replies View Related

C :: Program On Multiplication Of Matrices Using Functions

Feb 26, 2013

when i am running this program no errors are being shown but as soon as i press ctr+f9 to run the program my tc++ window closes.....

Code:
#include<stdio.h>
#include<conio.h>
void multiply(int m1[50][50],int ,int,int m2[50][50],int ,int );
void main() {
int i,j,m,n,p,q,m1[50][50],m2[50][50];

[Code] ....

View 4 Replies View Related

C :: Scanning Equations / Functions Into Program

Nov 15, 2014

I have to make a numerical integration program, how I can write my code so that the user is able to write their own function that they want to integrate?

E.g. they would see the message: 'please enter your function' and would be able to write whatever they wanted e.g. 'x +5' then this would then be integrated by the program.

I have already written a program that can integrate a known function but would prefer that the user could choose their own.

View 2 Replies View Related

C++ :: Program To Check Validation Of Functions

Apr 12, 2013

I'm writing a program to check whether codes from a file are invalid, valid, inactive, or valid and active, but can't get it to work properly. The invalid codes are being found, but the other three are not. I think it may have something to do with my "active" function.

#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
using namespace std;

struct ActiveCodes {
string code;
bool flag;

[Code] ....

View 19 Replies View Related

C :: How To Make Custom Program For Packaging Multiple Files In One

Nov 5, 2014

I want to make a custom program for packaging multiple files in one. Not as complicated as ZLIB or others. Consider few files, XML, txt, JPG, OGG, I want them to be added in 1 file. Not visible not readable. Just a datafile. I have some ideas about creating some kind of indexing of the start byte, end byte of each file. But I am still way too far. Can you point me some direction at what should I stress in creating this software. It will be portable since I am planning to use stdlib, stdio only, maybe and string to recreate the filenames from the large chunk datafile.

View 2 Replies View Related

C++ :: How To Program A Hash Map System Where Each Key Have Multiple Values Under Indexes

Nov 13, 2013

How difficult would it be to program a hash-map system where each "key" can have multiple values under indexes?

For example: "Word" -> 45(index 0) , 67(index 1) , 12(index 2). What could I start with to program this or where could I find a pre-made system that does this?

View 14 Replies View Related

C :: Calling Functions From Parallel (MPI) Fortran Program

Apr 24, 2013

I'm working on a parallel Fortran program by using MPI, which calls a very good random number generator function from C (drand48 and srand48 for seed).

My Fortran program file "Par_PICFort_4.f95" is smt. like:

Code: PROGRAM main
IMPLICIT NONE
Include 'mpif.h'

[Code]....

I compile the code as: Code: mpif77 -o PIC Par_PICFort_4.f95 drand48.c Program seem to be running, but after checking the simulation results, I see that drand48 is not working in a parallel way. Creating independent random numbers which different seeds is very important for me.

Question: Is it possible to run the drand48.c file as parallel?

View 2 Replies View Related

C :: ATM Program - Withdraw And Fastcash Functions Are Not Working

Apr 19, 2013

My ATM program compiles but my withdraw and fastcash functions are not working right in my program.

Here is my program:

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

int fn_balance(int *);
void fn_deposit(int *);
void fn_withdraw(int *);
void printReceipt(int *);
void mainMenu(int *);
void FastCashMenu(int *);

[Code] .....

View 1 Replies View Related

C :: Using Prototype Functions To Run Loops And To Pause The Program?

Oct 25, 2013

So i have to use these prototype functions to run loops and to pause the program, the only problem is after i select a loop option and enter a number of dots to print in the loop it goes into an infinite loop and why, also when i try using the 4 option to exit it still asks me how many dots i want to print.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int pause(char *);
int getInt(char *);
void whileFunction(int);
void doWhileFunction(int);
void forFunction(int);

[Code] .....

View 12 Replies View Related

C :: Write A Program With Two Functions Both Called From Main

Mar 14, 2013

Write a program with two functions both called from main(). The first function just prints "Hello". In the second function ask the user to enter a number. Calculate the square root of the number and return the result to main(). In main() print the square root value.

Code:

#include<stdio.h>
#include<math.h>
float fun3 (float );
main()
}

[code]...

View 3 Replies View Related

C++ :: Use Functions In A Program To Show Names And Grades

May 19, 2013

how to use functions in a program to show the names and grades of students, their average, total, highest and lowest grades.

View 1 Replies View Related

C++ :: Program To Display Other Functions In Int Main Function

Oct 13, 2013

I would like my program to display other functions in the int main function. For example, this is what my program looks like:

int Function1(int &var1, int &var2, int &var3) {
cout << "blah blah blah" ;
cin >> var1 ;
var2 = var1 * 3 ; //example
var3 = var1 * var2 ; //example
if(blah blah blah)

[Code]...

View 2 Replies View Related

C/C++ :: Menu Driven Program - Value Returning Functions

Apr 2, 2015

I'm working on what I thought was a pretty simple program. I'm writing a menu driven program that will allow users to obtain specified measurements of several geometric figures. I was trying to test each each time I add a function.

I keep getting this error. error C3861: 'AreaOfSquare': identifier not found.

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int menu() {
int choice;

[Code] ....

View 4 Replies View Related

C/C++ :: How To Retrieve Stored Procedure Functions In Program

Oct 3, 2012

Stored procedure functions about c program

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







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