C/C++ :: Can't Get Basic Input / Output Program To Work
Feb 29, 2012
im trying to write a program that prompts the user to enter three numbers and then prints them vertically (each on one line), first forward and then reversed. this is how the design should look:
enter three numbers: 1 43 54
your numbers fowards:
1
43
54
your numbers backwards:
54
43
1
this is what i have thus far when it comes to code....
#include <stdio>
int main (void) {
// local declarations
int a;
int b;
int c
[code].....
View 1 Replies
ADVERTISEMENT
Feb 23, 2014
I been for trying to create 5x5 2d array that
basically display first column, last column , and diagonally (like " N " display). but i cant get it to work.
this is what i have so far.
int _tmain(int argc, _TCHAR* argv[]) {
char Test[5][5];
for (int i = 0; i < 5; i++)
[Code]....
View 4 Replies
View Related
Mar 11, 2014
The problem that I am having is that , the program outputs numbers that are perfect numbers and im not sure where i can add a statement to make it so that if it isn't a perfect number it doesn't output...
#include<iostream>// allows user input/output
#include<conio.h>
#include<fstream>//data file / result file
#include<iomanip>
#include<cmath> // math function
#define in_file "data.txt"
#define out_file "result.txt"
[Code] ....
View 3 Replies
View Related
Apr 27, 2013
In my class we were supposed to write a program from the book that inputted the names and votes and the program is supposed to spit out who won the vote. I did this then while i was reading the assignment from the instructor I noticed he wanted the information inputted from a TXT file instead of manually inputting it. I cannot seem to get it to work....
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
#define N 5
char names[N][20];
float votes[N];
[Code] ....
here is the txt file
Johnson 5000
Miller 4000
Duffy 6000
Robinson 2500
Ashtony 1800
View 2 Replies
View Related
Oct 21, 2012
Write a C++ program that does the following:
Prompt the user to enter a day of the week as M (or m), T, W, R, F, S, and U for Monday through Sunday respectively. The user may enter an upper or lower case letter.
When the user enters a character, the program will echo the letter and output the name of the day of the week.
Provide an error trap that reads something like "you have entered an invalid letter; program aborting." Suggestion: use a switch statement with the error trap as the default condition. it is not necessary to prompt for multiple inputs.
So I know how to get the program to echo back the letter and everything. What I am a little confused about is: will I have to define all the letters as their respective day? eg. make M== Monday. And if I do have to do that how would I get it to accept Upper and Lower case letters and recognize that that letter is == monday ect. ect.
Also my main problem is the switch statement as the error trap. I have never used the switch statement, but I know what they do. I just don't really understand how I would use it for an error trap. Am I suppose to just make a case for every other letter in the alphabet other then M T W R F S and U? Even if I do that then what if the user enters a number instead of a letter?
View 4 Replies
View Related
Mar 2, 2014
// this program gives random number output
#include <iostream>
#include <cstdlib>// contains function protype for rand
#include <iomanip>// for setw
using namespace std;
[code]....
what is the effect on output of program of different numbers input to the int data type named seed*/
View 1 Replies
View Related
Feb 4, 2013
Code:
#include <stdio.h>
main() {
int c, n1;
n1 = 0;
while ((c = getchar()) != EOF)
if (c == '')
++n1;
printf("%d", n1);
}
I have a more complicated program I'm wishing to have display the output, however, to save some time I'm using an example of a shorter version. count the lines in input and display the output in terminal when ./program is executed after compilation. To count and compute lines, words and within arrays.
View 4 Replies
View Related
Sep 29, 2013
I am having trouble with an assignment. The assignment consists of a basic encryption and decryption program already written for me, I just have to write the encryption function. What we have to get the program to do is enter an integer and a text, and get the program to increment each letter in the text by the integer given. I did this by using a for loop and incrementing each value in the string by the integer.
However, I still can't get it to decrypt and I need the program to work with only a-z letters (if I increment each letter by 3 and I have the letter Z, it should go to Z+3 = C).
I attached the description of the attachment and below are the codes: The first file does not need to be edited.
Code:
/*******************Programming Assignment 1***************/
/****************Caesar's substitution cipher**************/
/*****************YOU MUST NOT EDIT THIS FILE**************/
/****Substitute alphabets in a string using rotation key***/
/****Leave all other characters unchanged******************/
/****Confirm correct encryption by decrypting**************/
[Code] ......
View 1 Replies
View Related
Feb 4, 2014
Code:
#include <stdio.h>
void Swap(int *x, int *y);
int *Largest(int *array, int size);
int main()
{
int a, b, i;
int c[10];
int maxaddress;
}
[code]...
My swap function works fine, but I am trying to find the ADDRESS of the largest element in my array and I am getting an error using gcc on my "return &largest;" and my printf line in my main function.How can I fix this and return the address of the largest?
View 8 Replies
View Related
Feb 22, 2012
I have created a simple basic program that uses sockets but it can only handle one connection, how do I make it so it handles multiple connections?
Server code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
}
[code]...
View 5 Replies
View Related
May 18, 2014
This is my program
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
struct date
{int dd,mm,yy;}
[Code] ....
Error in Line 11:Too many types in declaration
View 2 Replies
View Related
Nov 12, 2014
I'm basically trying to create a program that will project a soccer teams points for the whole season. Here are the basics:
Total games: 38
Win: 3 pts
Draw: 1 pt
Loss: 0 pts
My program compiles fine, but inevitably crashes right before the if statement..
Code:
#include<stdio.h>
int main(void)
{
float ppg, games_played, games_left, points_earned, pts_proj;
char team_one;
}
[code]....
View 4 Replies
View Related
Aug 6, 2014
I am trying to send yahoo mail using socket program.
Using the commands like ehlo, starttls, auth login, data,.,quit.
but starttls is error. yahoo close itself. one more thing i use this same method for gmail is working.
The problem is we must enable the ssl authentication. Like System.net mail in .net package smtp.enablessl=true. how i enable ssl authentication in starttls in c++ program
View 1 Replies
View Related
May 16, 2014
I tried to build a basic username-password verification program; I already have 2 text documents, usr.txt and pass.txt in which username and password are stored. Then have written this program to check the username and password, but every time it says Access Denied.
Here's what I have written:
#include<stdio.h>
#include<conio.h>
void main()
[Code].....
View 6 Replies
View Related
Aug 29, 2014
One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows:
John K. 99, 87, 57, 89, 90, 95
Amanda B. Jones 100, 88, 76, 99, 86, 92
etc..
The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the last (2) at 30% each.
Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
[Code]....
View 2 Replies
View Related
Oct 19, 2014
I am making a very basic parent/child class based program that shows polymorphism. It does not compile due to a few syntax errors reading "function call missing argument list. Lines 76 and 77, 81 and 82, and 86 and 87.
#include<iostream>
using namespace std;
class people {
public:
virtual void height(double h) = 0;
virtual void weight(double w) = 0;
[Code] ....
View 4 Replies
View Related
Nov 13, 2014
I cannot get my function overloading the input operator for rational type objects to work.
lab9.cpp: In function ‘std::istream& operator>>(std::istream&, const rational&)’:
lab9.cpp:186:20: error: invalid initialization of reference of type ‘std::istream& {aka std::basic_istream<char>&}’ from expression of type ‘rational’
return (inputFrac);
lab9.h
#include <iostream>
using namespace std;
class rational {
public:
rational();
rational(int a, int b);
[Code] ......
View 4 Replies
View Related
Mar 9, 2014
I have a program matrix multiplication but it work not for big arrays. n should be bis 200.
#include <iostream>
#include <time.h>
#include <cstdlib>
[Code]....
View 6 Replies
View Related
Apr 1, 2014
I have client-server program that written with c++. Both client and server program are working on my computer.Also, I test it on many computer.There is no problem with it.But, When I try to run that program on the my windows server 2003. I get error which on the below.
[URL] ....
I researched it and someone said that it is related 32-64 bit system . My windows server is 32 bit. And I am compiling as 32 bit. But I still get error , can not get any answer with it.
View 2 Replies
View Related
Dec 9, 2013
how work backspace key in c++.i want to make a program which can work as a backspace number
View 1 Replies
View Related
Nov 12, 2014
Title is self-explanatory.
Code:
#include <iostream>
using namespace std;
int main ( ) {
float number;
float sum;
float divi;
while(number != -1) {
[Code] .....
View 5 Replies
View Related
Sep 14, 2013
I have this code:
Code:
#include <stdio.h> //printf
#include <stdlib.h> //exit
#include <unistd.h> //fork
#include <sys/types.h> //pid_t
#include <sys/wait.h> //waitpid
}
[code]....
I would like to, when running cat, send in some data like "testing" to its stdin, and then catch the output of stdout, and put it into a character array variable.Currently the parent stalls till the child is done.I imagine the parent has to some how detect that the child executed 'cat', and then send in input to stdin?Then somehow detect that 'cat' is done executing, and read the output from stdout? I have looked around and found "dup2", but I don't understand how to send in and get data to the child from the parent, especially since the "file descriptors" is not pointing to any files in the first place..
View 4 Replies
View Related
Feb 5, 2015
So I have a project in which I am processing audio signals in real-time. I want to create a class to do this using the ASIO driver. I don't want to use a cross platform library nor do I want to use windows API as it is very slow.
View 2 Replies
View Related
Sep 7, 2014
I'm trying to write something that when a user is at the command line, the user can type and it displays of list of commands the user can use to run the application.
View 14 Replies
View Related
Mar 31, 2013
I have a program that needs to output the input with a setprecision of 2 but when it outputs 0, it has to be "0", not "0.00"
How will I go about that?
Here is my code:
void PrintAllSales(double sales[][SLSPRDT]) {
cout << fixed << showpoint << setprecision(2) << endl;
cout << "ALL SALES
";
WriteLine('=', 63);
[Code] .....
And here is how it comes out:
1234
ALL SALES
===============================================================
Product # | 1 | 2 | 3 |
Salesperson 1 | 2000.00 | 0.00 | 299.00 |
Salesperson 2 | 0.00 | 2543.98 | 95.99 |
Salesperson 3 | 0.00 | 0.00 | 19.99 |
Salesperson 4 | 0.00 | 3854.75 | 0.00 |
But it should be like this:
1234
ALL SALES
===============================================================
Product # | 1 | 2 | 3 |
Salesperson 1 | 2000.00 | 0 | 299.00 |
Salesperson 2 | 0 | 2543.98 | 95.99 |
Salesperson 3 | 0 | 0 | 19.99 |
Salesperson 4 | 0 | 3854.75 | 0 |
View 7 Replies
View Related
Sep 11, 2012
I have a project, a montly paycheck. So it checks the monthly paycheck of each employees. but my problem there is how to add a new employee when u are a user or in the output of program?
View 2 Replies
View Related