Visual C++ :: Program Doesn't Accept Input Values True?

Nov 1, 2014

I am making a program which is going to print out a head image according to the input values entered by the user. Here is the code:

Code:
#include <iostream>
#include <string>
using namespace std;
void Sides()
// draws the sides to take proportion

[Code] .....

At first i tried to work program like:

Code:
cout << "plase enter which way you want to print out the head, with parted hair or bald." << endl;
cin >> headstyle;
if (headstyle != "bald" || headstyle != "parted hair" )

But it also had given the same mistake. The program compiles BUT; even if I put in the values bald or parted hair the program prints out "wrong input" then exits.

View 2 Replies


ADVERTISEMENT

Visual C++ :: Program Must Accept 7 Values Or Stop It When Type S

Oct 27, 2014

I want to fix this code. The program must accept 7 values or stop it when you type s. The code not only couts the element, but also some other random numbers.

Code:
#include<iostream>
using namespace std;
int main() {
int numb[7];
int i;
char s;
for (i=0;i<=6;i++)

[Code] .....

View 2 Replies View Related

C++ :: Program Only Accept Integer From 0-10 But Doesn't Show The Factorial

Feb 28, 2013

#include<iostream>
using namespace std;
int main() {
int a[9],x,f=1;
cout<<"Please enter an integer [0-10 only] : ";

[Code] ....

View 3 Replies View Related

C# :: Accept Two Input Parameter And Returns Two Out Values

Jan 26, 2014

class Program {
//Accept two input parameter and returns two out value
public static void rect(int len, int width, out int area, out int perimeter) {
area = len * width;
perimeter = 2 * (len + width);

[Code] .....

why is the static keyword required in the method signature for the rect() method. It will not compile if it is absent. why?

the same is true for this example:

class Program {
static void printvalues(params int[] passedin) {
foreach (var printthis in passedin) {
Console.WriteLine(printthis);

[Code] ....

This code won't compile without the static keyword in the printvalues() method signature. why?

View 13 Replies View Related

C++ :: Program That Accept Input For User ID

Oct 28, 2013

I need a program to run that will accept an input for user id. It will take the customer input and capitalize the letters, and return invalid id with the user inputted values. Then if it's valid it will add a counter counting the number of letters and numbers. It will keep track until the user puts in !. It seems when I try to pass values from the array to my toUpper function to capitalize it it doesn't seem to work right.

View 3 Replies View Related

C :: Program To Accept Only Numerical Values And Gives Error If Character Or Symbol Entered

Nov 11, 2013

How can i make my program to accept only numerical values and gives a error notice if a character or a symbol is entered???

View 4 Replies View Related

C++ :: Input Validation - Program Cannot Accept Negative Numbers

Nov 12, 2014

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

// Function Prototype
void sortArray(int array[], int size);

[Code] ....

This program was made to allow students to enter as many test scores as they want and the program will show them in ascending order and then will calculate the average of all test scores. It works wonderful until you enter a negative test score and then it throws the averaging process off. I can't seem to be able to make the program not accept the negative numbers.

View 1 Replies View Related

C++ :: Copy And Paste Function From Other Source Program Doesn't Wait For Input

Nov 27, 2013

I'm working on a project that requires to make modifications to certain functions. So, I'll copy and paste the function to a new source code so I'm just working on the function with the entire program running. When I run the function by itself, it works fine. But when I copy and paste the function back to it's spot, the program doesn't wait for input at the cin.getline & it did wait when I ran just the function by itself. I'm using Dev C++ if that makes a difference.

View 2 Replies View Related

C++ :: Create 1 Variable That Accept Any Type Of Values?

Aug 24, 2013

Can I create 1 variable that accept any type? And can I give it the NULL value too?

View 14 Replies View Related

C++ :: New Project Doesn't Cout Any Values?

Apr 11, 2014

I'm trying to build a new project and i installed some new libraries in it but when i try to compile any code it doesn't give me any value just press any key to continue, i didn't make any files but one and even if i tried to do this simple task it doesn't cout any result:

#include<iostream>
using namespace std;
int main() {
cout <<("ha");
system("pause");
return 0;
}

View 4 Replies View Related

C# :: Array Doesn't Return Values

Jun 26, 2014

While working on another issue I started memory cleaning and refactoring. While refactoring I decided to create an array Resize Array Reize and Null Count:

Spoiler

public int NullCount(string[,] Original) {
try {
int returnInt =0;
for(int x =0; x<= Original.GetUpperBound(0);x++) {
if (Original[x,0]==null )
{returnInt++;}

[code]......

View 6 Replies View Related

C :: Accept Password From Standard Input And Goes Through All Possible Combinations Until It Matched

Dec 24, 2014

I've been experimenting a bit and can't find a decent way to make a brute forcing script that accepts a password from standard input, and goes through all possible combinations until it is matched. How to structure the code?

View 1 Replies View Related

C :: Accept Input Number From User And To Convert It Into Array Of Integer

Oct 7, 2014

i was trying to solve a problem in SPOJ and what i wanted to do is to accept an input number from the user and to convert it into a array of integer.

Code:

#include<stdio.h>
int * toarray(int *num);
int main(void)
{
int testCases;
}

[code]....

But whenever i try to print the array in the main function i get only two value and the rest address

Code:

1//number of testCases
23456 //input number
6
2293452
4
2293700
1974439125

Process returned 0 (0x0) execution time : 4.152 s
Press any key to continue. However, if i tried to print the array from within the function, it prints the numbers just fine.

print the array elements from the main program, so that i would be able to go on with the rest of it

View 1 Replies View Related

C++ :: Accept Signed Decimal Integer As Input And Output In Binary

Jan 29, 2015

Write a C++ application program to accept a signed decimal integer as input and output the equivalent 2s complement version in 16-bit binary. Include a space between every four bits in the output string. The input will only be processed by the application if it falls in the valid range that can be represented in 2s complement format with 16 bits. The range of a decimal number from - to + is -32768 to 32767.

View 3 Replies View Related

C++ :: Accept Input Till User Hits Enter With No Text Typed

Feb 27, 2012

It seems to be going null. I can't get a null value, I want it to accept input till the user hits enter with no text typed. I've tried checking to see if the input is NULL, "", and " " all to no avail.

Code:
#include <stdio.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <iostream>
#include <fstream>
#include <string.h>
#include <cstring>
using namespace std;
int main() {
string info = "";

[Code] ....

View 7 Replies View Related

C :: Program That Grades A True / False Quiz - Data Available In Text File

Oct 14, 2014

You are to write a C program that grades a true-false quiz. The quiz data will be available in a text file; here is an example:

Quiz #8 (09/22/14) (corrected version)
TTFTTFTFTF
0080 TTFTTFTFTF
0340 TTFTFFTFTF

The first line in the data file is a comment that you may assume can be up to 80 charac- ters long; it cannot be blank. The second line contains the answer key for the 10-question true-false quiz. The following lines in the data file contain a student's id number in column 1 followed by their answers for the quiz in column 2. A 0 (zero) on a line by itself indicates that there are no more students to process.

Write a program that first reads in (from standard input; more on this in a moment) the comment line and answer key as strings followed by each student's data. Store the student's id numbers in an array. You are to "grade" each student's quiz using the key provided fol- lowed by recording their scores (in a second array) in order to be able to print them out later. You do not need to use an array of strings or characters in your program. Write your program allowing for up to 100 students, and you may assume that at least 1 student will have taken the quiz.

You should create test data text files and provide the data to your program using redirection from the command line (see the sample run below). Your program should output the number of students who took the quiz, the average score, the best score, and a table showing each student's id, score, and grade. The formatting, spacing, and labels in your output should 1 match the sample run below exactly.

Your program should determine each student's grade as follows: if the score is equal to the best score b or b−1, give an A. If it is b−2, award a B. Give C's for any score that is equal to b−3 or b−4, a D for b−5 and an F for all others.

Alright So I'm just stuck at comparing the key answer with student answer here is my code comparing one student's answer with the answer key . is that right ?? One more thing for some reason when i try to print answer[0] the result is nothing why is that

Code:
#include<stdio.h>
int main(void) {
char comment[80];
char answer [10];
char studentans [10];
int n=0,i=0,x=0;
int ID[10];

[Code] .....

View 1 Replies View Related

C++ :: Create Program That Will Accept 2 Integers?

Sep 4, 2013

how can I create a program that will accept 2 two integers. the user will also choose among the different operations:

1 for addition
2 for subtraction
3 for multiplication
4 for division

View 4 Replies View Related

C# :: Program Won't Accept Database Information Using Parameters

Apr 30, 2014

I am creating a WinForm registration application and my program accepts user input information and stores it but I am struggling to use my login function. I believe there is an error in the area of cmd.Parameters.AddWithValue section, I dont think addwithvalue is correct ? I get a fatal crash has occurred when I click Login

string constring = "datasource=127.0.0.1;port=3306;username=root;password=welcome";
string Query = "SELECT * FROM 'userinfo'.'users' where 'username' = @userid and 'password' = @password)";
MySqlConnection conDatabase = new MySqlConnection(constring);
MySqlCommand cmd = new MySqlCommand(Query, conDatabase);
cmd.Parameters.AddWithValue("@userid", this.userid_txt.Text);
cmd.Parameters.AddWithValue("@passone", this.passone_txt.Text);

[code]....

Fixed the crash error, simple typo but now I am getting SQL Syntax errors which I originally believed I fixed.

View 1 Replies View Related

C++ :: Program That Accept Positive Integer - Use Do While To Allow User To Continue Or Not

Aug 10, 2014

So this is the activity (LOOPING) :

Write a program that accepts a positive integer. The program should be the same from the given output. Use do while to allow the user to continue or not.

OUTPUT must be:

n = 5
0
1==0
2==1==0
3==2==1==0
4==3==2==1==0
5==4==3==2==1==0

if n = 6
0
1==0
2==1==0
3==2==1==0
4==3==2==1==0
5==4==3==2==1==0
6==5==4==3==2==1==0

View 2 Replies View Related

Visual C++ :: Program To Display Values From Data File As Image?

Jul 29, 2014

I am writing a program to display values from a data file as an image. But I can only get a blue screen. Here is a small program resembling my code. what I have missed? I only changed OnDraw function.

Code:
void CColorDisplayView::OnDraw(CDC* pDC) {
CColorDisplayDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CRect rect;

[code].....

View 10 Replies View Related

C++ :: CString Program - Function Should Accept String Object Arguments

Feb 23, 2015

Write a function named replaceSubstring. The function should accept three C-string or string object arguments.

Let's call them string1, string2, and string3. It should search string1 for all occurrences of string2. When it finds an occurrence of string2, it should replace it with string3.

For example, suppose the three arguments have the following values:

string1: "the dog jumped over the fence"
string2: "the"
string3: "that"

With these three arguments, the function would return a string object with the value "that dog jumped over that fence." Demonstrate the function in a complete program.

View 1 Replies View Related

C++ :: Program Compiles But Doesn't Run

Apr 28, 2013

My program compiles but doesn't run, Here is the screen shot of debugging

//DynBag.cpp : Implementation File
#include <stdexcept>
#include <iostream>
#include "DynBag.h"

[Code] .....

View 3 Replies View Related

Visual C++ :: Windows 7 Explorer Doesn't Get Refreshed

Aug 4, 2013

I have created an application to burn my data files into DVD. The problem which I am facing is as follows:

Suppose I have a folder "Doc_Files" present inside "D:Data" location for burning into DVD. The correct behaviour of the application is, after writing the "Doc_Files" folder into disc, I have to immediately delete this "Doc_Files" folder from the "D:Data" location.

I am calling the DeleteFile() Win32 API for deleting those files which are present inside "Doc_Files" folder.

The files are getting deleted successfully but they are still shown in the same folder untill I do not terminate the application.

Till the application is up those files are still visible even after they are deleted. And as soon as I kill my application and refresh my data folder those files are gone, and the folder becomes empty.

I am making use of IMAPI interfaces and methods for burning process.

View 3 Replies View Related

C++ :: Program Doesn't Alphabetize Strings

Jan 18, 2015

I can't seem to get my program to alphabetize a vector string. It displays the names, but not in a sorted order.

void sort_names(vector<string> &nameList) {
int i, minIndex;
string minValue;
int size;
size = nameList.size();

[Code] ....

View 4 Replies View Related

C++ :: Program Doesn't Read The End Of File Sequence

Aug 16, 2014

i have a question, i'm studyng the string library type and i have to write this program :

Code:

std::string word;
while (std::cin >> word) {
std::cout << word << std::endl;
}
why if my input is :

hi my name is ^Z

the output is :

hi
my
name
is

why the program doesn't fall out from the while loop ?

why my program does not recognize my sequence of end of file ?

View 5 Replies View Related

C :: Program Doesn't Print Data From Socket

May 7, 2014

I created a basic socket server, which listensing for incoming udp data. When I run the netcat program, I get a response:

Code:
$ nc -luv 1732
Connection from 10.50.11.12 port 1732 [udp/*] accepted
(?@??8?? ??.?n?5
(?@??8?? ??.?n?5|?>)
(?@??8?? ??.?n?5|?>)
^C |?>)

But with my c program it doesn't give the response. It should say something like "here is the message: " and then give a message.

Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>

[Code] .....

View 2 Replies View Related







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