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
ADVERTISEMENT
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
View Related
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
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
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
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
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
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
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
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
Oct 7, 2012
I'm attempting to write a program that displays an array of labels; however, I can't seen to make the labels appear in the form. I've set some of the properties, but still not luck.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
[Code]...
View 4 Replies
View Related
Mar 8, 2013
Is it possible to create a function that can both return and display a value. I was trying to make a program that computes and prints terms of the Fibonacci series using a recursive function.
View 3 Replies
View Related
Oct 1, 2014
This is just the portion of my program. This program displays Not Found even if the id number is found.
void search(void) {
char ID[10];
int i, found;
cout<<"Enter ID to search: ";
gets(ID);
found=0;
for(i=0;i<top;i++)
[Code] .....
Here's the incorrect output
Enter ID to search: 111
Not found
Name: jude
ID: 111
Semester: 1
Major: IT
I just want to remove the "Not found".
View 1 Replies
View Related
Nov 18, 2014
I'm not sure why Im getting a wrong Sum. of the Columns.
Write a method that returns the sum of all the elements in a specific column in a matrix using the following header:
double sumColumn(const double m[] [SIZE], int rowSize, int columnIndex)
Write a test program that reads a 3-by-4 matrix and displays the sum of each column. here is a sample run:
Enter a 3-by-4 matrix row by row:
1.5 2 3 4
5.5 6 7 8
9.5 1 3 1
Sum of the elements at column 0 is 16.5
Sum of the elements at column 1 is 9.0
Sum of the elements at column 2 is 13.0
Sum of the elements at column 3 is 13.0
#include <iostream>
using namespace std;
const int SIZE = 4;
int rowSize=3;
[Code].....
View 1 Replies
View Related
Aug 1, 2013
I've read that we can write a program that displays a menu of commands for the user to choose from.We can write some functions that implement these commands, then store pointers to the functions in the array :
Code:
void ( *file_cmd[])(void) = { new_cmd , open_cmd }; // 2 cmd's for simplicity
We can get a similar effect with a switch statement but using an array of function pointers gives us more flexibility since the elements of the array can be changed as the programm is running.
I decided to write an example about this in order to understand better the context, I am facing some problems though :
Code:
#include<stdio.h>
#include<stdlib.h>
typedef void (*p_foo) (int);
void foo(int x);
void foo2(int y);
[Code] .....
The problems are :
Code:
TEST2.c:9: warning: initialization from incompatible pointer type
TEST2.c:9: warning: initialization from incompatible pointer type
TEST2.c:25: error: too few arguments to function "*(arr + (long unsigned int)((long unsigned int)i * 8ul))"
View 14 Replies
View Related
Feb 27, 2013
The assignment is to create a program that displays the median of an array using pointers. Assume the array is already in ascending or descending order.I'm getting errors currently on the bottom two "return median;" statements.The code that I have so far is as follows...
#include <iostream>
using namespace std;
char again;
int getMedian(int*, int);
const int constant = 100;
[code]....
View 3 Replies
View Related
Oct 24, 2014
write a program that computes the factorial of a number and displays it. A factorial of a number (written N!) is defined as N * (N-1) * (N-2) * (N-3) ... *1 In other words, 5! = 5 * 4 * 3 * 2 * 1 = 120 and 3! = 3 * 2 * 1 + 6.
Example of output 15 is 1.30767e+012
Can't get it to display error when user enters a number lower than 2 or higher 60.
// Program to calculate factorial of a number
#include <iostream>
#include <iomanip>
[Code].....
View 13 Replies
View Related
Apr 24, 2014
I'm new to C programming and in my first computer science class. Our assignment was to write a program that displays each digit of an integer in English. I wrote the following but cannot figure out why it won't display zeros. When I execute and type in the number 1,000, I get "zero."
Code:
#include <stdio.h>
int main (void)
{
int x, y = 0;
printf ("This program displays each digit of an integer in English.
[Code] ....
View 5 Replies
View Related
Jan 23, 2015
I'm trying to create a program that takes an integer input and displays each digit on a new line from right to left.
An example of this would be:
Enter an integer: 657
Digit (1): 7
Digit (2): 5
Digit (3): 6
So far I have this:
#include <stdio.h>
#include <math.h>
int main() {
int i, input, output;
printf("Enter an integer: ");
scanf("%d", &input);
if(input == 0)
printf("Digit (1): 0");
[Code] ....
It works perfectly fine, but I just learned that I am not allowed to use the #include <math.h> so I have to take out floor, log, and pow.
I'm pretty sure I have to do some sort of while or for loop to get the results, but how to do it.
View 6 Replies
View Related
Oct 28, 2013
so in declaring a display function prototype only that displays a student test scores in the format (student name tab number of scores tab test scores )
is this right?
#ifndef STUDENTTESTSCORES_H
#define STUDENTTESTSCORES_H
#include <string>
using namespace std;
class StudentTestScores{
private:
[Code]...
and also how do we call the display function if it is in a class from the header file onto the main cpp file.
View 2 Replies
View Related
Feb 18, 2013
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.
Code:
//-----------struct ------------//
struct Node
{
char data;
struct Node *next;
}*Head;
[code]....
View 1 Replies
View Related
Jan 25, 2015
So i have made an array and made a scanf in a for loop so it can store all numbers entered from keyboard in the array but i dont know how to put the numbers that are less than 5 in another array and then print that array out and the lenght of the array.
View 11 Replies
View Related
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
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
Nov 19, 2014
Write a template that accepts an argument and returns its absolute value. The absolute entered by the user, then return the total. The argument sent into the function should be the number of values the function is to read. Test the template in a simple driver program that sends values of various types as arguments and displays the results.
#include <iostream>
using namespace std;
template <class integertemplate>
integertemplate totalint (integertemplate integers) {
cout << "How many integer values do you wish to total? ";
cin >> integers;
[Code] .....
View 8 Replies
View Related
May 24, 2013
In this code:
// Ex10_15.cpp Using lambda expressions
#include <algorithm>
#include <iostream>
#include <iomanip>
[code].....
The lambda accepts no arguments, but it accesses increment by value and current by reference, the latter being used to store the next value to be set. This lambda has the side effect that current will be updated when generate is finished. The following lambda expression is similar, but without the side effect:
[=]()mutable->T{T result(current);
current += increment;
return result;}
"
I dont exactly understand what side affect it is talking about. Wouldn't you want generate to update current? I understand how the second code fixes it though, just takes everything in the enclosing scope by value.
View 2 Replies
View Related