C++ :: Store And Print String On Screen

Sep 20, 2013

Given this sentence as an input: "Hello my name and "John" (with its spaces and capital letters), print it on the screen .. NB the phrase must be entered from the keyboard all at once ... you can do this in C / C + +?

View 3 Replies


ADVERTISEMENT

C/C++ :: Program To Store Info About Students And Then Display To Screen

Oct 7, 2014

NOTES AT BOTTOM---EXPLANTION, PROBLEMS ETC. SCROLL DOWN

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

[Code]....

I have to write a program that stores information about students and displays results (Formated). Example-

Inputs ( # of students, First and Last name of student, the gender, age, and hieght. (height inputed as inches and outputed as feet and inches))

Student 2
---------
Jett, Joan Female
100 years old 5' 7"

Ive been falling behind a little due to working late and barely having time for my school work. Coming across several issues, one being an error with GENDER (Error C4700: uninitialized local variable 'gender' used:). As well as how to format the end result, i understand that u have to use #include <iomanip>, but am confused on how to format correctly.

View 2 Replies View Related

C :: How To Get Sum Of Areas And Print On Screen

Mar 19, 2014

So i am struggling for days to get this done and all i need is to get the sum of the areas and get them printed on the screen my code is this:

Code:

#include<stdio.h>
#include <stdlib.h>
#include<conio.h> //Not needed in Dev C++//
#define PI 3.1415
float Area_of_Rectangular(float length,float width);
float Area_of_Circle(float radius);
int main()

[Code]...

View 7 Replies View Related

C :: Print The Inverse Number On Screen

Dec 25, 2014

Print the inverse number. Ex: 2178*4=8712

Write down a program which can satisfy the prerequisite and print out the screen.

The answer is:

Code:
void inverse2 ()
{
int i,j;
for (i=1000;i<=9999;i++)
for (j=1;j<=9;j++)
if (i*j==inverse (i))
printf("%5d%2d",i,j);
}

I can't understand the double for loop.

for (i=1000;i<=9999;i++)
for (j=1;j<=9;j++)

And The meaning for

i*j==inverse (i)

View 2 Replies View Related

C :: Printf Doesn't Print On Screen

May 23, 2013

This code runs. However, when I run it, the text from printf doesn't appear until after I type in the two numbers.

I use Wascana, will it run correctly on other compilers?

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
fflush(stdout);

[Code].....

And this is how it turns out on the screen:

Code:

6
3

What size is the die:

how many dice to roll:

Numbers are 3d6
Rolling die no.1...
RolledDie: 4 DieTotal: 4
Rolling die no.2...
RolledDie: 5 DieTotal: 9
Rolling die no.3...
RolledDie: 5 DieTotal: 14

The total is: 14

View 4 Replies View Related

C++ :: Recursion - How To Print To The Screen Value Of N After It Has Been Multiplied

Mar 20, 2013

How to print to the screen the value of n after it has been multiplied.

For example: if I use cout << "n: " << n << " power: " << power << "
"; I

can see the variable "power" decrementing by 1, but I don't see the variable "n" incrementing with its new value after it has been multiplied by n * n.

#include <iostream>
using namespace std;
typedef unsigned short int USHORT;
typedef unsigned long int ULONG;

ULONG Getpower(USHORT n, USHORT power);

[Code] .....

View 2 Replies View Related

C++ :: Check If A Number Is Odd Or Even And Print It To The Screen

Mar 8, 2013

My objective is to check to see if a number is odd or even and print it to the screen just to make sure its working correctly.

The data file contains:
138
402 2 485
9
43
98 805
58
421
948 7 97
48
67
35
42
948
579 39 12
700 20 500 210
98

I can get the numbers to print fine using:

fstream infile1(argv[1]);
if(!infile1.is_open())
cout << "Could not open file";
else {
char listNum;
while(infile1.get(listNum))
cout << listNum;
}

However, when I check for odd or even numbers it will check each and every number.

printed like this (partial list):
1 is odd 3 is odd 8 is even
9 is odd

But it should print:
138 is even
9 is odd

I tried using getline, but it keeps giving me the errors:
invalid conversion from 'void*' to 'char**'
invalid conversion from 'char' to 'size_t*'
too few arguments to function 'ssize_t getline(char**, size_t*, FILE*)'

Here is the getline code, what am I doing wrong? I have tried switching things around, adding things. Just nothing works.

ifstream infile1(argv[1]);
if(!infile1.is_open())
cout << "Could not open file";
else {
char listNum;
getline(infile1, listNum);
cout << listNum;
}

View 2 Replies View Related

C/C++ :: How To Print Results On Screen Without Using Printf

Jun 26, 2013

how to print the result on screen without using printf in C...?

View 6 Replies View Related

C++ :: Make Output Print Out To Screen In Reverse?

May 26, 2013

How can I make the output print out to the screen in reverse?

Code: #include <iostream>
#include <iomanip>
using namespace std;
int getnum();
void Fibonacci(int n);

[Code].....

View 7 Replies View Related

C :: Program To Print All Of Prime Numbers To Screen

May 29, 2013

I'm trying to write a program that prints all of the prime numbers to the screen. I'm getting angry because it only prints EVERY number. I think it has something to do with the bool change not being able to leave the for-loop but how to fix it.

Code:
#import <stdio.h>
#include <stdbool.h>
int main(void){
printf("
The Primes Are: 1");

[Code] ....

View 3 Replies View Related

C :: Any Way To Read Entire File And Print It On Screen

Feb 26, 2013

is there anyway to read an entire file and print in on screen? file consists of strings and integers!

View 7 Replies View Related

Visual C++ :: How To Print Mathematical Series On Screen

Nov 24, 2013

How do I print a mathematical series such as

1 + 2/2! - 3/3! + ...... n/n! //n is read from user

Not only we need to print the series on the screen but at the same time find the sum using simple loops.

View 1 Replies View Related

C :: Return Errno From Open Function And Print It To Screen

Mar 22, 2013

i am programming Cli/Ser ,so part of the program is to open file to download it from client side,but i want to return the global value Errorno to print it to screen , and how to use strerror() func ??? i write this "This is part of server code" :

Code:

fd= open("abc.txt",O_RDONLY);
//error handilng in open file
if(fd<0)
{

[Code].....

View 3 Replies View Related

C :: Program Won't Correctly Print Proper Totals On Screen

Oct 10, 2014

Why this program won't correctly print the proper totals on screen? See my code and the included screenshot.

Code:
#include <stdio.h>
int main(void) {
int total, first, second;
printf("Enter 2 numbers:

[Code] .....

View 4 Replies View Related

C/C++ :: Passing Two Dimensional Array To Function And Print To Screen?

Apr 4, 2015

This seems simple enough but I'm missing something here to make this code work.What I'm trying to do is print the contents of the two dimensional array in 25 rows and 4 columns. I experimented with something similar to this code when I initialized the array with numbers.

#include <iostream>
#include <iomanip>
#include <cmath>

[Code].....

View 1 Replies View Related

C/C++ :: Passing Two Dimensional Array To Function And Print To Screen

Apr 4, 2015

I'm getting garbage. I tried including the name of the array in the cin object but I got an error message that says "no match for operator '>>'. When I take the name of the array out, the program compiles but I get garbage. Program is suppose to reads data from a file of 25 students and calculates test scores and class grade average output each student's name score, letter grade and grade average. I would be happy at this point if I could just print out something that wasn't garbage.

Here is the code.

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <fstream>
using namespace std;
//const
const int Array_Row = 25;
const int Array_Col = 4;

[Code] ......

View 1 Replies View Related

C++ :: Search By Word In Text File And Print Out Whole Line On Screen

Apr 7, 2013

I have a text file where in each line is 3 words and 2 int type numbers. I'm doing search by word and I want to print out to the screen the whole line where that word was found (the words is repeated in some lines). My search looks like this:

Code:
#include<iostream>
#include<string>
#include<fstream>
#include<stdlib.h>
#include <vector>
using namespace std;
int main(){
vector <string> words;
string str, paieska;

[Code] .....

How to print line(s) where I found that word?

View 9 Replies View Related

C++ :: Print Custom Area Of Screen - Save As Image File

Sep 9, 2014

I am trying to automatically(periodically) print screen a custom area of the screen, save it as an image file (the image will have the same format always), and then use OCR to get the text in the image as usable string variables. Is this doable? I was looking into tesseract OCR but I find it a bit unclear.

View 10 Replies View Related

C++ :: Convert List Of Binary Numbers From A File Into Decimal And Print To Screen

Sep 23, 2014

I am trying to make a program that will convert a list of binary numbers from a file into decimal and print the decimal to the screen. I have no problem doing the conversion, the problem comes up when our teacher wants the input file in a format as such:

3
10110101
11111111
10101010

The first number is supposed to tell the program how many different 8bit strings it is going to have to convert, and then the following lines are those binary numbers.

I am not very experienced with file inputs, and I know how to open files and read lines in.. The problem is, how to say "ok the first line says 3, so now I have to convert the next 3 lines" . I am assuming it is just a simple loop that I am missing....

View 4 Replies View Related

C/C++ :: Program That Read A Number From Keyboard And Print Separated Digits To Screen

Feb 18, 2015

Basically this is what i need to do. Write a program that reads a number from the keyboard, separates it into its individual digits and prints the digits to screen, each on its own line followed by the same number of stars as itself.

For example, if the number is 2339 the program should print

9 *********
3 ***
3 ***
2 **

So far i have managed to separate the number and have them on different lines, but how to implement the stars onto each line with the number!

My code so far:

int main() {
int n;
printf("number? ");
scanf("%d", &n);
while (n > 0) {
printf("
%d

[Code]...

View 4 Replies View Related

C++ :: Program Read In 15 Integers From User Then Store And Print Out Numbers

Apr 29, 2014

I want to write a program to read in 15 integers from the user, and then store them in a 5x3 array, and print out the numbers as a 3x5 array.

View 7 Replies View Related

Visual C++ :: Text Size In Screen Is Different From Size In Print Preview?

Feb 1, 2013

I must take an old MFC project in VC++ 6.0 and make changes.

The problem is text size in screen is different from size in print preview.

for example with this font

Code:
CFont f50;
f50.CreateFont(100,0,0,0,FW_BOLD,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE,"Frutiger LT Std 45 Light");

And this text

Code:
s=_T("Let's try to calculate the size of this text");

and with MM_LOMETRIC map mode

GetTextExtent() returns me:

On screen: (1595,99)
Ink printer + print preview: (1589,100)
PDFCreator + print preview: (1580,100)

comparing with screen size the height is bigger but lenght is smaller. I don't understand.

I can understand that different printers process the fonts in different way and then to have different lenghts. That's not the problem. The problem is I need to simulate in screen the same behaviour i will have on printer because these texts are being aligned in the document, and I don't want to see that the text si aligned different in text than in paper.

What can I do to render the text on screen with the same size I will have on the printer? Print preview is doing it. Should I change the font parameters? is something related with pixels per inch?

View 4 Replies View Related

C :: Declared A String Constant And Trying To Print Length Of String

Oct 9, 2014

In this code, i declared a string constant and trying to print the length of string. I know that if i write char a1[7] or char a1[] than it runs and give aggregate output, but in this case it is giving double length of string.

Code:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
}

[code]....

View 5 Replies View Related

C :: How To Store First String Into A Variable

Feb 11, 2013

Im trying to write a program that reads in strings and decides if the 1st one is repeated. I cant figure out how to store the first string into a variable, and compare that variable to the rest of the inputted strings.

Code:

#include <strings.h>
#include <stdio.h>
int main () {
//Declared variables
int i;
}

[code]....

View 3 Replies View Related

C :: Best Way To Store Input String Into Char

Sep 16, 2013

I'm extremely rusty at C but is this the best way to store an input string into a char*?

Code:
int length = 100; //initial size Code: char * name = malloc(length * sizeof(char)); //allocate mem for 100 chars
int count = 0; //to keep track of how many chars have been used
char c; // to store the current char

while((c = getchar()) != '
'){ //keep reading until a newline
if(count >= length)

name = realloc(name, (length += 10) * sizeof(char)); //add room for 10 more chars
name[count++] = c
}

Is this a good way and what could be better?

View 2 Replies View Related

C++ :: Split A String And Store Into 2D Vector

Oct 14, 2014

I am having trouble with parsing out string value into a 2D vector. Suppose i have the string "attack at dawn " consisting of 15 characters, i will like to store it into a 2D vector with 5 rows and 3 columns and the result is as follow.

Vector[0][0] = "a"
Vector[0][1] = "t"
Vector[0][2] = "t"
Vector[1][0] = "a"
Vector[1][1] = "c"

[Code] ....

View 1 Replies View Related







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