I am building a linked list and i need to display function i have. The display function displays all the letters of the word entered instead of the word itself. below is my struct, one of my functions and the display function.
I am having trouble getting the stars to output correctly in the printStars function. the final output should look something like this:
#include <iostream> using namespace std; int readArray(int input[], int size); void printArray(int input[], int count); void printStars(int input[], int size);
I'm trying to create a function that determines the largest value in the array and then outputs the value and index. I want to values in the array to be random so I tried using the rand function, although I'm not sure where I'm supposed to put it. My main problem (I think) is outputting the correct values...
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; void lastLargestIndex (int numbers[], int arraySize); int main(int argc, char** argv) { int number, arraySize = 50;
I have an assignment which requires me to do the following:
Required to write a function that finds an integer in an array and returns its corresponding index. The function must be called findNumber. It must have FOUR parameters:
- The first parameter is the array to be searched - The second parameter is the integer to be found within the array - The third parameter is the size of the array - The fourth parameter is an integer that indicates whether the array is sorted. A value of 1 means the array is sorted; a value of zero means the array is not sorted.
Since a function can only return one value(To return the position of a required integer in an array in this instance) I have tried to make use of pointers to try and return a value stating whether the array is sorted or not.This is my code : (It compiles perfectly but it does not produce any outputs)
Code:
#include <stdio.h> #define SIZE 10 size_t findNumber(int *sort, const int array[],int key,size_t size); int main(void){ int a[SIZE]; size_t x;
I had the idea to write a program that would convert a decimal integer into any base up to 36 (there are no letters after that) so I decided to give it a try.
Code: #include <stdio.h> #include <stdlib.h> char letters(int r); // prototypes function for converting 10's to A's and so on, base 11+ will work int main() {
int base; int d; //declares decimal integer int d_clone; // clones d for a loop
For the program, you will write a utility that converts dollars to coins. It is a simple program that must have the following:
-Multiple outputs to the screen -At least one input -The use of integers and strings -Looking or repetition with Do..While, If..Else -Must have some output text to show correct value of coins that would be converted from the dollars. -Code must include comments explaining your reason for the code section or what the code is doing -Code must compile -Whole dollars only. If value is less than 1 or 0, the program should break or exit. -Turn in your source code (.cpp file) to your instructor with your filename including your first and last name and your compiled executable.
I've reached a point in "Jumping into C++" where I need to make a program that converts input numbers into their word equivalent.
So far I've made it work for numbers 0-9999. I've tried implementing 10000-99999 but there are problems with the order of the words printed (57865 would print fifty thousand seven thousand eight hundred sixty five). But besides that, the program is absolutely enormous (for me) and I'm wondering if it can be shortened. Keep in mind I can only use loops and if statements so far. Here it is:
My program takes in an input file from the command line and converts the string from the file into a linked list and then depending on the command it will manipulate the string to either reverse the list, print the list, or take a character out...I'm having trouble taking a character out, my code compiles fine but doesn't change the string at all
i m learning c programming and i m stuck with this program for some reason.Write a program that converts alphanumeric phone number into numeric form:
O/P: Enter phone number: CALLAT 2255288 here is the code i have written: /** compilers shows no error **/ and O/P I get is Enter phone number: CALLAT /**blank space***/
I'm trying to write a function which can recognize whether a word is a palindrome. if it's the case , it must return 1 on screen, otherwise 0. This is the code which return 0 even in case of a palindrome...
Code: int IsPalindrom(char String[]){ int i,l; int counter=0; for(i=0;;i++){ //counts the number of array elements
I was wondering about the function strcmp(), does the function compare word with spaces? eg: If I have two same words "Harith Javed"; will it match both words??
I've written a function that has to receive a word as parameter, and then has to find the amount of times that word (uppercase & lowercase) occurs in a text file:
For example, if the word "the" is sent as a parameter, the total amount of times the words "the" and "THE" occurs in the text file, has to be calculated.
However, my function is not displaying the correct amount, what is wrong with my function:
int WordCount :: countWords(string wrd) { int counter=0; string temp = "";
Basically I have a text file called words. I'm supposed to extract a word randomly form the file and have the user guess the word. If they guess the word correctly in x number of tries they will receive the definition.
I'm having trouble receiving that random word and I'm getting the definitions from the file.
This is what is in the words.txt file apple#the usually round, red or yellow, edible fruit of a small tree boat#a vessel for transport by water horse#a solid-hoofed plant-eating domesticated mammal with a flowing mane and tail, used for riding television#a system for transmitting visual images and sound that are reproduced on screens soup#a liquid dish, typically made by boiling meat, fish, or vegetables, etc. bottle#a container, typically made of glass or plastic and with a narrow neck barber#a person who cuts hair toast#sliced bread browned on both sides by exposure to radiant heat radar#a system for detecting the presence, direction, distance, and speed of aircraft, ships, and other objects red#of a color at the end of the spectrum next to orange and opposite violet
I'm learning programming, and C++. I've got a question, but I couldn't solve my problem so far. I need to use arrays and only basic stuff to solve this:
Create a program that reads a word from the user and then print (cout) this word on contrary. It's simple, I know, but I can't do it,. I've tried some stuff but I don't get how I will get the proper values to do this. All I know is that I can use variable.lenght().
I've taken part the text into 1 word per line, but I can't figure out how to printf every word only once and then add (%d) in the end to show how many repetitions of that word there are.
Code: #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; int main(){ char *oneword;
I have text (string) and I want to find a given word (it's ok!) and then insert another given word after the first word. The original string is beeing copied into a new string. But something is going wrong!!! Where is my mistake?
(I have some patches...)
Code:
#include <stdio.h> #include <stdlib.h> #include <string.h> //insert "new_word" after each occurence of "word" int main(){ char A[100]="In the sentence words the and the.";
i'm making a program for basic data entry.i have also included search feature which uses strcmpi() function.if i have a file name'report on tigers' and someone searched for 'tigers' then that person will not find the required file.any way i can overcome that ?
I could trace the above one of the mistakes where the array initialization is crossing the array limits and writing into array[32] which is not available. My question does it overwrite into array1 as it is declared below array or it can write into any other location.