C++ :: Program That Accepts Array Of Characters

Nov 18, 2014

Here's the question: Create a program that accepts an array of characters. And displays the converted array of characters into Upper case if it is given in Lowercase and vice versa. Don't use string, but char.

Example: mychar ="I am A conQUeror."
Code: //My Codes:
#include <iostream>
#include <conio.h>
using namespace std;
int main()

[Code] ....

View 5 Replies


ADVERTISEMENT

C :: Program That Accepts First / Last Name And Displays It Through Another Function

Sep 25, 2014

I was trying to code a program that accepts your first name and then last name and then displays it through another function. I have checked that the assignments are between similar type of variables and pointers, but I don't seem to get it right.

When first input is taken and then second one, the first one's value changes to same as the second. E.G if first name is L and second name is S and after second input both variables, first and sec, become equal to S. Why?

Code:

#include <stdio.h>
#include <stdlib.h>
//FUNCTION PROTOTYPES
char *input(void);
void show(char *f,char *s);

[code]....

View 7 Replies View Related

C++ :: Program That Accepts Two Input From User?

Dec 8, 2013

I built a program that accepts two input from the user, using a array inside a loop, it is pass to a function inside a class which will display the two number, the problem is when the user is inputting a number and it is 1 the program continuously as the user to input a number, and when 2 is entered the program ask another number and end, but for example you entered 2 and 3. . . it will then outpu 2 and 4 (so 3 + 1 ) and always the last number is plus one. here is the code.

main.cpp
#include <iostream>
#include "newclass.h"
using namespace std;

[Code].....

View 5 Replies View Related

C++ :: How To Modify A Program So That It Accepts Columns Instead Of Rows

Feb 4, 2015

I have a N queens (actually 8 queens to be specific) program that accepts the numbers in order by row. I need to get it so it accepts the numbers in order by column. At first glance I thought it was just one space different, but it turned out not to be and how to get the one space difference in there. My current code (which I'm aware isn't doing the column accepting right) is:

Code:

#include <iostream>
using namespace std;
int main() {
int board[8];
cout << "Enter the columns containing queens, in order by column: ";
for(int i = 0; i < 8; ++i) {
cin >> board[i];

[Code]...

What the output should be:

Code:

Enter the rows containing queens, in order by column:

7
6
5
3
4
2
1
0

.......Q
......Q.
.....Q..
...Q....
....Q...
..Q.....
.Q......
Q.......

What it is:

Code:

Enter the columns containing queens, in order by column:

7
6
5
3
4
2
1
0
........Q
.......Q.
......Q..
....Q....
.....Q...
...Q.....
..Q......
.Q.......

View 5 Replies View Related

C/C++ :: Program That Accepts Information And Calculated CGPA

Jan 30, 2015

i want to display the grade report of two students in the table but this code will repeat the grade report of one student in the tables and what is wrong with this code below ?

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

[Code]....

View 3 Replies View Related

C++ :: Looping Activity - Program That Accepts Positive Integer

Aug 10, 2014

You pros are once newbies like us. Hoped you might take a little time sharing your expertise. Got freaked out when our teacher gave us this activity, where she haven't taught this to us yet. 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 5 Replies View Related

C++ :: Program That Accepts Three Images And Combines Them Into Panoramic View

Aug 15, 2013

I've been tasked with righting a program that accepts three images and combines them into a panoramic view I'm having trouble getting started?

View 2 Replies View Related

C++ :: Function That Accepts Array Of Integers And Its Size As Arguments

Feb 12, 2014

Write a function that accepts an array of integers and its size as arguments. The function should create a new array that is one element larger than the argument array. The first element of the new array should be set to 0. Element 0 of the argument array should be copied to element 1 of the new array, element 1 of the argument array should be copied to element 2 of the new array, and so forth.

The function should return a pointer to the new array. Use ONLY pointer parameters instead of arrays in both functions; use pointers (not subscripts) to move through elements of both arrays. Before calling the function, display your original array. When the function call is completed, display the new array.

Here is what i got so far:

#include <iostream>
using namespace std;
int *shifted (int * , int);
const int SIZE = 10;
int main () {
int array_size [30];

[Code] ....

View 1 Replies View Related

C/C++ :: Write A Function That Accepts Two Arguments / Array Of Integers

Feb 16, 2014

write a function accepts two arguments, an array of integers and a number indicating the number of elements in the array. the function should recursively calculate the sum of all the numbers in the array. Demonatrate the use of the functions in a program that asks the users to enter an array of numbers and prints it sum

i had done this but it wont work

#include <iostream>
#include <conio.h>
#include <iomanip>
using namespace std;

[Code].....

View 6 Replies View Related

C :: How To Print Characters But No String Just Array Of Characters

Mar 20, 2014

so my question is i want to print characters,no string just an array of characters,i do this but it s not working,maybe i have to put the '' at the end?

Code:

int main() {
int i;
char ch[5];
for(i = 0; i < 5; i++) {
scanf("%c",&ch[i]);

[Code]...

View 6 Replies View Related

C/C++ :: Check For Set Of Characters In Array Of Characters?

Mar 26, 2014

I have an array of characters. I am trying to find "houston". The only way I can think of to do this is to use a for loop and check each individual character. Is there an easier way to do this?

char string[] = "Fishing tourism miami atlanta dallas houston";

View 9 Replies View Related

C++ :: Using Loop To Process Array Of Characters Starting From Beginning Of Array?

May 3, 2014

Assume you want to use a loop to process an array of characters starting from the beginning of the array. You want the loop to stop when you read the null terminator character from the array. Fill in the loop test condition that will make this work correctly.

index = 0;
ch = array[index];
while ( _____________________________)
{
// process the character
index++;
ch = array[index];
}

View 1 Replies View Related

C++ :: Changing Array Of Characters To A String Array?

Apr 7, 2013

I have an array titled: char TypeOfSong[arraySize] where the array size is 15. I am reading data from a file into this array and the characters can be either 'C', 'D', 'E', or 'R'. Each of these characters stands for a word (sting) and when I output the array, I need the strings to show up, not the characters. I have been reading online and in my book but I can only find information on turning one array with the same characters into a string. How would I go about changing this character array with different characters into a sting?

The characters stand for:

C = Country
D = Dance Party
E = Elevator
R = Rock

View 5 Replies View Related

C/C++ :: Testing Character Array Against Array Of Characters?

Apr 16, 2014

I am currently having an issue with validating user input for a state abbreviation. I have an array where a list of abbreviations is stored to use as a comparison for whatever the user inputs. I have been able to get the list loaded properly but whenever i go to compare, it always comes back as true even if it isn't. Here is some relevant code:

static char stateTable[STATE_TABLE_SIZE][STATE_SIZE];
int main() {
char buffer[40], *testCustName[40], testState[5], testCode;
buffer[0] = '';
int quit = 0;
int p = 0;

[code].....

View 6 Replies View Related

C/C++ :: How To Initialize Array Of Pointers To Array Of Characters

May 21, 2014

I am trying to initialize an array of pointers to an array of characters, I can do it in 3 lines but I really want to do it in one line at the same time keeping the #define.

3 lines initialization (can compile)
======================
#define A 1
#define B 2
char row1[] = {A|B, B, A};
char row2[] = {B, A};
char *test[]= {row1, row2};

1 line initialization (failed)
===============================
char *test[] = { {A|B, B, A}, {B, A} }; // <- how do i do this??

I do not want this because it waste ROM space
=============================================
char test[][3] = { {A|B, B, A}, {B, A} };

View 18 Replies View Related

C++ :: Program To Verify That Name Only Contains Alphabetic Characters?

Dec 1, 2013

I am working on a program where i prompt the user for his/her name and i have to verify that the name only contains alphabetic characters.

here is my coding. It works to an extent i just can't get it to work the way it is supposed to.

#include <iostream>
#include <cstring>
using namespace std;
const int SIZE = 50;
int main()
{
char name[SIZE];
cout << "What's your first name?" << endl;

[Code]...

when someone types in a name with only alphabetic characters it outputs valid name for how long the name is. For Ex: bob is three characters so it would output valid name three times. also when you put in a name with a number or character at the end it outputs valid name for the correct characters but also outputs the invalid character and invalid name which its supposed to do. the valid name should not be showing up though.

View 2 Replies View Related

C/C++ :: Program To Count Different Types Of Characters

Sep 24, 2014

My goal is to create a program that reads a string and counts how many Uppercase, Lowercase, Spaces, and digits there are in the string. Right now this the output i get.

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main() {
int iochar;
char string;

[Code] .....

View 1 Replies View Related

C :: Create A Proper Table That Accepts Value In Each Box It Contains

Sep 29, 2013

I want to create a proper visible table with boundaries that contains boxes and each box receives a value .I don't know where to start from.i have an idea of using matrix for entering values in each box of table,but how to create lines and boundaries ?

View 1 Replies View Related

C++ :: Add Constructor That Accepts One Argument And Uses It To Set Radius

Apr 10, 2013

I'm getting a error on my Circle::Circle(double radiusValue) constructor. My instructions is 'Add a constructor that accepts one argument and uses it to set the radius.'

#include <iostream>
#include <cmath>
using namespace std;
class Circle {
private:
double x;
double y;
double radius;

[Code] .....

View 3 Replies View Related

C++ :: Write Program That Outputs The Number Of Characters?

Jun 3, 2013

I need to write a program that outputs the number of characters, words, and lines in the files that are supplied as command-line arguments.

#include <iostream>
#include <string>
#include <iomanip>

[Code]....

View 2 Replies View Related

C/C++ :: Program To Count Uppercase And Lowercase Characters

Sep 22, 2014

#include <stdio.h>
#include <string.h>
int main() {
char string[100];
int c= 0, count[26] = {0};
printf("Enter a string: ", string);

[Code]...

This is the output I receive:

I need counting the Uppercase Letters.

View 3 Replies View Related

C++ :: Function That Accepts Integer And Returns A String?

May 5, 2014

How to go about making a function that accepts an integer and returns a string with any one of 5 strings containing the name of the object. For example object number 3 might be "Pen". Object 4 might be "Paper".

To do this would I just use an array?

View 4 Replies View Related

C/C++ :: Program To Read In And Count All Printable Characters (ASCII 32-126)

Feb 12, 2014

I'm writing a program that reads and counts all the printable characters (ASCII 32-126)found in a text file.

For example if the text file read: Why so serious?

The output to the screen would display(in order of ascii value however):

Character-----Total
W--------------1
h--------------1
y--------------1
s--------------3
o--------------2
etc...

However, I don't think it's reading any of the characters.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <string>
using namespace std;
int main() {
int i, count[127];

[Code] .....

View 2 Replies View Related

C :: Compress Array Of Characters

Mar 15, 2014

I am trying to write a function compress() that takes in an input of a 2-dimensional array (5x10) of character data, compresses each row of the array by replacing each run of character with a single character and the number of times it occurs, and prints on each line the result of compression in the function. For example, the row with data aabbcdddee may be compressed into a2b2c1d3e2.

Input (5x10 of characters):
aaacccdeee
sssseeeedd
aaaaaaaccc
eeedddasee
ddeeeeeggg

Output:
a3c3d1e3
s4e4d2
a7c3
e3d3a1s1e2
d2e5g3

I could achieve the compression part, but behind the compressed array, it printed out 5 extra lines of alien ASCI code, followed by printing out 5 times of everything .

Code:

void compress(char data[SIZE1][SIZE2])
{
int i,j, k,l ,count;
char data123;
printf("Enter your data (5x10 of characters): ");
for (i=0; i < SIZE1; i++) {
for (j=0; j < SIZE2; j++)
data[i][j] = getchar();
fflush(stdin);
}

[code]....

View 3 Replies View Related

C :: How To Read The Characters Into Array

Jan 27, 2014

I have written this program to copy all the characters input from the keyboard into the array till a "?" mark is entered. what is the error i am doing. I am getting a run time error in this case.

Code:

void word_reversal(void) {
char array[100];
int index=0;
printf("Enter the number of characters less than 100
");
do {
scanf("%c",&array[index++]);
}while(array[index] != '?');
}

View 8 Replies View Related

C/C++ :: How To Switch Characters In Array

May 1, 2014

I have tried to search all about strings,I have the occurrences and have worked out what letter corresponds with which. I have searched that much i can remove the vowels and reverse my string but I dont know how to swap them. This is what i have this far. When it compiles it just prints the decipher is:

If i even find out am i on the right track ive used caps when swapping to try and stop the doubles over writing,...

#include<stdio.h>
#include<string.h>
int main(void){
int i,count=0;
char secretText[] = "lopsy, hssepokd wl okrhsowk:

[code]....

View 1 Replies View Related







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