473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Having input from a user and making each word in the input on its own line. If it is

Read a sentence from the console. Break the sentence into words using the space character as a delimiter. Iterate over each word, if the word is a numeric value then print its value doubled, otherwise print out the word, with each output on its own line.

http://pastebin.com/WqS5zit2

I am having trouble figuring out how to double the number in the input.
Feb 2 '14 #1

✓ answered by weaknessforcats

If your word is 100, you have three char values. You would need to convert these chars into an int, double the int, and print the int. You would not change the int back into a word of three chars 200.

The library function atoi converts a string to an int.

Expand|Select|Wrap|Line Numbers
  1. int y;
  2.     y = atoi(your word);
  3.  
You need to include <stdlib.h>.

All you need do is display 2* y.

1 1988
weaknessforcats
9,208 Expert Mod 8TB
If your word is 100, you have three char values. You would need to convert these chars into an int, double the int, and print the int. You would not change the int back into a word of three chars 200.

The library function atoi converts a string to an int.

Expand|Select|Wrap|Line Numbers
  1. int y;
  2.     y = atoi(your word);
  3.  
You need to include <stdlib.h>.

All you need do is display 2* y.
Feb 2 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: kernelxu | last post by:
hi,everybody. I calling function setbuf() to change the characteristic of standsrd input buffer. some fragment of the progrem is: (DEV-C++2.9.9.2) #include <stdio.h> #include <stdlib.h> int...
2
by: Eric Lindsay | last post by:
I recently came across a site http://maetl.coretxt.net.nz/?m=xhtml-design-patterns which displays as one word per line in Opera and Safari, but as a normal page (with a different font) in Firefox...
3
by: turnitup | last post by:
Dear all, I have a problem with a form, and I have tried various permutations of htmlentities() and html_entity_decode() to resolve, but without success. Here is the workflow. 1: User...
1
by: kumarm | last post by:
Hi I need some help reagrding how to read word document line by line using vb.net program?. I have a word object created by using vb.net program which opens a word document.Using this object my...
3
by: kumarm | last post by:
Hi I need some help reagrding how to read word document line by line using vb.net program?. I have a word object created by using vb.net program which opens a word document.Using this object my...
3
by: Prakhar | last post by:
Hello, I know the subject line gives a little idea about the problem. Well, I want to get the input ,and after taking the input, I AGAIN want to get the same input. For Eg., Suppose input...
0
boxfish
by: boxfish | last post by:
Hello, I'm trying to make a kind of complicated overloaded input operator in C++, and I need to look ahead a couple of characters on the input stream, and not remove them from the stream until I know...
1
by: vivekgrs | last post by:
hi friends i want 2 read the data from word document line by line. can anyone help me. i can able 2 read data in text file by using filesystemobject. regards vivek
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.