C/C++ :: Have To Identify Odd Number And Print Them
Apr 10, 2013#include<stdio.h>
#define TRUE 1
int formOddInt(int n);
[Code]....
#include<stdio.h>
#define TRUE 1
int formOddInt(int n);
[Code]....
is there a to use printf to print certain number of blank spaces, where the number is derived from the output of a function?
for(m=low; m<=high;m++)
{
printf("t=%2d %'f(m)-1's %3c", m, ' ',*);
}
This is suppose to output
t=-3 *
t=-2 *
t=-1
.
.
.
I need to write a program that will allow the user to enter a number "n" and the program tell you that the nth prime number is .....
EXAMPLE
user enters 55
printf("The 55th prime number is %i", variable");
How to reserved int number and print as float number ?
View 1 Replies View RelatedI have this homework where i am implementing a code which does error checking
so basically i have 3 variables and i assigned them as integer. so my error check is asking that if i type a value for instance 1.2 it should output "X"...
I wanna write a class for polynomials, but there are some bugs in my code. I want to identify a polynomial with two arrays of the same length, one that contains the exponents of the nonzero monomials, and the other that contains the coefficients itself.
for example: (shematically)
3x^2 +5x^100 shoud be identified by array1=(2,100) and array2=(3,5)
the size of that polynomial should be Dim=2.
it should be possible to change the size dynamically.
Code:
#ifndef poly
#define poly
#include<cassert>
class poly {
[Code] ....
PROBLEM1 the destructor isnt working:
virtual ~poly() {delete [] start;delete [] koef;} //destruktor
Error: This declaration has no Storage class or typ specifier.
Error: Expected an identifier.
PROBLEM2 the constructor isnt working:
poly::poly(int x=0)
Error: Expected an identifier
Error: Expected a )
Error: Expected a ;.
I dont know what the computer want to tell me??
I want to implement some "debugger like" tool (very limited one, just identify at running time the current stack trace, and print messages from the user) on some code that the user wrote. what I get from the user is a function name (in the beginning of it's declaration), and when the user want to print some message he uses some print macro I should implement.
My target is printing the stack call, and all the messages that the user wrote, in the right place on the running place.
By what c++ feature can know on running time that a specific function code has ended??
Its easy to push a function to some vector when it called (since I get its name from the user), but when it ends and return to the function called it...
We know that function pointer for virtual function are stored in a vtable.When we have multiple function pointer entry in vtable and we call one of the virtual function then how the corresponding or correct function pointer is retrived from Vtable? Who do this stuff? In assembly code i can not see any code or logic to detrmine the correct function pointer.
View 4 Replies View RelatedI have a dialog app with two separate static controls. Both controls have been subclassed from CStatic derived class to implement drag and drop and double clicking. The class works just fine, but I cannot figure out which of the controls is being double clicked or dragged and dropped onto because I only have the code below operating. I need some method in the derived class to determine which control is being manipulated.
Code:
// header file
#pragma once
#ifndef __AFXWIN_H__
[Code]....
Identify the invalid C expression or choose "all are valid". Assume all variables are integer and non-zero.
7.
a) a+b-0 b) c+-a%4 c) xm6-24 d) xf3r6+2
e) all are valid
8.
a) xx+yy%zz b) z%(z%z%z)) c) ha+ha+ha d) x23-20.4
e) all are valid
[Code] ......
I am supposed to make a histogram. I succeeded in generating the integers for the histogram. But what I want to do is instead of displaying numbers in the console, I want something like "*" displayed for every integer there is in an array. It should look something like this.
*
****
*****
********
**********
******
****
***
*
As far as I understand, in some way I need to identify the integer in the array and for every single one of them I need to insert the symbol. I don't know how to identify it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1{
class Program {
static void Main(string[] args) {
diceHistogram();
[Code] .....
How can i print out the SECOND MIN number and MAX number without using array?
cout << "Please input a positive integer: ";
cin >> input;
min = input, max = input, secondmin = input;
do {
cout << "Please input a positive integer: ";
cin >> input;
[Code] .....
i just started learning programming and i just wanna know how come when i try to print the last digit of a number the output always become 6?
View 4 Replies View Relatedi want to print Largest number from any 5 rows.Th number printed should be any one of the largest in the five rows of 2d arrays.I have created code for largest number in each row but how to pick and print them randomly?.
Code:
#include<conio.h>
main( )
{
int a,b,c,d,e,x;
int arr[] = {a,b,c,d,e};
int Matrix[5][5] ={ /*Initializing array*/
2,4,3,5,9,
6,8,2,2,10,
[Code]...
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)
when i compile and run it it gives me the number 0 and not the proper number stored in array.
Code:
#include <stdio.h>
int main()
{
int myArray[11] = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };
}
[code]....
Basically i want to input a number for example 123456 and get back how many 7's are in the input number and also to print out that same number with stars in between like this *1*2*3*4*5*6*. Here is what i have so far:
#include <iostream>
using namespace std;
int countSeven(int x){
if(x == 7)return 1;
int c = 0;
while(x/10 > 9)c++;
return countSeven(x/10)+1;
when i compile it does not do what i tell it it just tells me there are 0 7's in the input number no matter how many there really are...
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;
}
The program works, but the rational number doesn't print as reduced. I guess i have to call the reduction function, but i'm not sure where
the output that i get is:
2/6 + 7/8 = 58/48
58/48 = 1.20833
2/6 - 7/8 = -26/48
-26/48 = -0.541667
2/6 x 7/8 = 14/48
14/48 = 0.291667
2/6 / 7/8 = 16/42
16/42 = 0.380952
the output that i suppose to get is:
1/3 + 7/8 = 29/24
29/24 = 1.20833
1/3 - 7/8 = -13/24
-13/24 = -0.541667
1/3 x 7/8 = 7/24
7/24 = 0.291667
1/3 / 7/8 = 8/21
8/21 = 0.380952
here is my header file
//Prevent multiple inclusions of header
#ifndef RATIONAL_H
#define RATIONAL_H
//Rational class definition
class Rational {
[Code] .....
Write a program to print out the binary value of a 16 bit number.
Create integers i, count, and mask.
Set 'i' to a hex value of 0x1b53.
Set mask to a value of 0x8000. Why?
print a line to show the hex value of i and then the leader for the binary value like this: Hex value = 1b53 Binary=
Use a for loop to loop 16 times and print 16 digits, using count as the loop counter
To test for each digit value, bitwise and 'i' with 'mask'
when the result for the bitwise and is true, print the number '1'
when the result for the bitwise and is false, print the number '0'
then shift mask one place to the right
print a new line and then quit
Use prtscrn and make a hard copy of the code with the console output.
Extra: use the modulus of count and print a space after every 4th digit to make the binary easier to read
The output should look like this: Hex value = 1b53, Binary= 0001 1011 0101 0011
so far this is what i have
#include <stdio.h>
#include <stdlib.h>
int main() {
int i, count, mask;
// 1B53 0001 1011 0101 0011
// 8000 1000 0000 0000 0000
i = 0x1b53;
[Code] ....
it is telling me that there is an "else" without previous "if", also is the program that I wrote correct?
I created a richtextbox to input the text that I want to print, the command for printing which is the button and instead of printdialog box((PrintDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)) to be display, I created combobox which will display the available printers and then print.
Like this code bellow .
To get the available printers:
foreach (String printer in PrinterSettings.InstalledPrinters)
{
cbox.Items.Add(printer.ToString());
}
And the button for printing :
PrintDocument1.PrinterSettings.PrinterName = cbox.SelectedItem.ToString();
PrintDocument1.Print();
Now what I want to do is I will add some textbox to input the page number to be printed . For example the current pages in the richtextbox are 12pages when I'm going to run the program I will input in the textbox the page/s that I want like (3-7pages). How could it be ?
C programming, make it use a function call to print the smallest number? this is a program which prints out the smallest of three numbers within the main function that I was asked to write.Now the other question i am asked,5. Re-write the program, uses a function call to print the smallest number?
Code:
# include <stdio.h>
main()
{
int a,b,c;
int temp, min;
a = 100;
b = 23;
c = 5;
}
[code]....
I've written a program which takes a character string and then prints each character vertically so that for instance the string 123 can be written as
1
2
3
no what i need is for all the numbers from zero to the inputted number to print the numbers digits vertically but each number to be printed horizontally so that for instance an input of 11 prints
1 2 3 4 5 6 7 8 9 1 1
0 1
i've made it so that i can print all numbers up to the inputted number vertically; however, i am stuck with a method for making each number print horizontally as described above.
I'm working my way through some C exercises to get some practice and have hit a wall. I need to use a function to take a number, such as 1, and print out One.Here's what I've got so far:
Code:
#include <stdio.h>
int name(int n);
char numberOne[] = "One";
int main(void)
{
int n;
}
[code]...
However, when I run the code and enter "1" the only thing that gets printed to the screen is "(lldb)". I've tried changing it to doing it without variables and just printing "One" but that gave the exact same result.
I have most of the code working properly, but I'm having trouble with a certain area. Currently I have multiple 2D arrays. One is a char array and the other is an int array. In the int array I have to find the max number in each column, which I've done. The problem is, I need to print the max number's row in relation to the char array's row.
For example,
Code: int array[2][3] = {60 50 30 0 100 1}
The max numbers are 60, 100, 30.
char array[2][length+1] = {nameOne nameTwo}
How it needs to print:
nameOne has max score of 60.
nameTwo has max score of 100.
nameOne has max score of 30.
I just can't understand how to compare the two arrays in the right way, so it'll know that nameOne is associated with the numbers in row 0 and nameTwo in row 1, etc.
Coding for- To print all combinations of numbers that can compose a given number..
View 3 Replies View Related