C :: How To Print Largest Number From 5 Rows

Sep 26, 2013

i 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]...

View 9 Replies


ADVERTISEMENT

C :: Find Largest And Second Largest Number In Array With Their Position

Jan 30, 2013

find inserted numbers, let say 10 numbers and find the largest and second largest number with their position in an array?

View 3 Replies View Related

C++ :: Find Largest / Second Largest Number And Average

Apr 28, 2014

Write a program that uses two functions; one finds the largest number and second largest number; and second function finds the average. The data, comprising of 20 different temperature values, is available on a file.

View 1 Replies View Related

C++ :: Display Rows Up To N Using Print Array Function

May 25, 2013

the value of C(k,n) are known as the binomial coeficient and can be arranged in triangle that was known as pascal triangle.

i was been asked to create a program that can display rows up to n=9 using print array function.

C(k,n) = C(k-1,n-1) + C(k,n-1)

how should i start?

View 3 Replies View Related

C/C++ :: Print Rows Of Ascending Digits - Delete Other Ones

Dec 14, 2014

That is sequence "aasdf123456785fg87" will be transformed into "aasdf12345678fg". I need to do this task in two variants: at once using getchar and putchar and then with strings. The object is done, but I think it could be done more easier. My codes:

(1)
char flag = 0;
while ((c = getchar()) != '.')
{
if (isdigit(c))

[Code]....

View 5 Replies View Related

C/C++ :: Print Rows Of Ascending Numbers And Other Symbols?

Dec 16, 2014

for example having input "12345556asf87" we get "123456asf". I need to do this task with getchar and putchar, and the with strings. My programs aren't working

stream:
char c = 0, c_ = 0;
char flag = 0;
while ((c = getchar()) != '.')
{

[Code]....

View 1 Replies View Related

C++ :: Receive Number From User And Output Largest Prime Number

Nov 20, 2014

I am attempting to write code that receives a number from the user and outputs the largest prime number underneath the user's number. There are no errors in my code, but no matter what number is imputed, the program says the largest prime number is 1. I cannot find where the issue is in the code. Here is the code I wrote:

#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
bool isPrime(int num);//function prototype

[Code] ....

View 2 Replies View Related

C++ :: Print Square Roots Of Numbers With Rows And Columns

Mar 12, 2013

this is what i have so far

#include <iostream>
#include <cmath>
using namespace std;
int main () {
int v;

[Code] ....

im trying to get the program to print this as an example if the user enters 5 (the rounding of the decimal is optional).

1 1.41 1.73 2 2.24
1 1.41 1.73 2
1 1.41 1.73
1 1.41
1

why its not reading my for loop for rows its only doing columns ...

View 4 Replies View Related

C++ :: Input Three Integers From Keyboard - Print Smallest And Largest Numbers

Nov 18, 2013

I am trying to Write a program that inputs three integers from the keyboard and prints the sum, average, product, smallest and largest of these numbers. How do i go about it. What i dont know is how to come up with smallest and largest number .

View 1 Replies View Related

C# :: How To Count Number Of Rows Returned By SQL

Jan 29, 2014

I want know if the query returned zero rows or not.

Don't want to use count(*)

sql = "select * from TABLE where employeefirstname = @First order by EmploymentStatusDescription";
using (SqlCommand cmd = new SqlCommand(sql, conn)) {
cmd.Parameters.AddWithValue("@First", First);
reader = cmd.ExecuteReader();
} while (reader.Read())

View 7 Replies View Related

C :: Find Largest Number Of 3X3 Matrix

Jul 26, 2013

Its a code to find the largest number of a 3X3 matrix.The logic seems to be right........

Code:

#include<stdio.h>
main() {
int matrix[3][3],i,k,j,*a;
a=&matrix[0][0];
printf("Enter the elements");
for(i=0;i<=2;i++) {

[Code]....

View 7 Replies View Related

C :: Largest Negative Number In 2 Complement

Mar 3, 2014

In this exercise:The C Programming Language Exercise 3-4..It states the following: "In a two's complement number representation, our version of itoa does not handle the largest negative number, that is, the value of n equal to -(2 to the power (wordsize - 1)) ."

A char is one byte (255 bits). The range of an 8 bit variable using a two's complement representation is -128 to 127. Therefore -128 is the largest negative value. The statement in book suggests that the itoa function will not output -128 if we pass -128 as a parameter, because in itoa when we try to convert -128 to positive -128, the inverse of -128 is -128. However, I just ran this code in my computer and it successfully outputted -128.

Code:

#include <stdio.h>
#include <string.h>
#define SIZE 10
void reverse(char s[])
{
int c, i, j;
}

[code].....

View 2 Replies View Related

C/C++ :: Finding Third Largest Number Without Using Array

Oct 12, 2014

I want to find third largest character in ascii as alphanumeritic. The problem is i cannot use arrays. How can I find third largest number ? Have to I compare all chars with each other ?

void third_largest(){
char ch;
do{
scanf("%c",&ch);
}
while(ch!=' ');
}

The chars can be hold up to press space ...

View 1 Replies View Related

C/C++ :: Finding Largest Number In Loop

Feb 10, 2014

I need to calculate the expected time it takes to do an activity using a formula provided and after the loop is broken it needs to show the number of projects processed and the project with the longest expected time. I've got everything working except for finding the the project with the longest expected time. What I have here just keeps displaying the number of the last project processed regardless of if it was the largest or not, specifically lines 54-61 is what i can't seem to figure out.

#include <stdio.h>
int main( void ) {
unsigned int counter;
int projectnumber;
int optimistictime;
int realistictime;

[Code] .....

View 1 Replies View Related

C/C++ :: How To Find Smallest And Largest Number

Oct 18, 2014

Write a program that will find the smallest, largest and average of the values in a collection of N positive integer numbers.

View 12 Replies View Related

C++ :: Find Largest Prime Number K Of Array 1

Aug 30, 2013

While finding the primes , I do not know how to make it into one array so that...

View 7 Replies View Related

C++ :: Largest Prime Factors Of The Number 600851475143

Mar 23, 2013

What is the largest prime factor of the number 600851475143 ?

This is what I have. If I replace 600851475143 by 1000 (for example), it works fine until 2 divides 1000 to 500, 250, 125...but when it has to find the next divisible prime (ie 5) it cannot do that and the program stops working.

Code:

#include<iostream>
using namespace std;
bool find_prime(int number) {
int factor, num;
factor = 2;
num = number;

[Code] .....

View 1 Replies View Related

C++ :: Finding Largest Prime Factor Of A Number?

Mar 10, 2013

I am trying to find the largest prime factor of a number. But when I am trying to determine if a number is a prime number in the function:

int is_prime(int number), I am unable to exit the loop.

Here is the code:

#include<iostream>
using namespace std;
int is_prime(int number) //the problem is in this function {
int num = number;
int factor=0;
do{
num++;
for(int i=1;i<(num+1);i++){

[code].....

So when the program runs, it first divides 20 by 2, to get 10, then divides 10 by 2 to get 5. Since, // condition 1 is not met, it passes 2 to the function int is_prime(int number). The function is able to return 3, but cannot exit the loop when num is 4.

I think the problem lies in the function: int is_prime(int number).

View 5 Replies View Related

C :: Find The Largest And Smallest Number Entered By User?

Mar 6, 2015

How to find the largest and smallest number entered by a user. So far I'm able to add, find the average and count how many numbers are entered.

I'm just having trouble with find the max and min. I tried if statements and it breaks the program will it wont let me exit the while loop or the program will do a force close after entering a value.

Code:

#include <stdio.h>
#include <stdlib.h>
int main(){

int maxNum=0, minNum=0, value, count=0, sum=0;
double average;

[Code] ....

View 4 Replies View Related

C :: Program To Find Largest Number From 5 Row By 5 Column Matrix

Feb 27, 2013

I made the code that stores and prints 5 row by 5 column values but how to find the largest number from them.What should I do to find the largest number?If I use if-else then it would be very tedious but I think there is way out with for loop but still I can't frame the logic. Here is the code

Code:
#include<stdio.h>
main() {
int lnum[5][5];
int i,j;
for(i=0;i<=4;i++) {

[Code] .....

View 7 Replies View Related

C++ :: Finding Smallest / Largest And Average Number - Do While Loop

Sep 10, 2013

I am stuck looking at whats the problem ....

#include <iostream>
using namespace std;
int main() {
float average, largest = 0, smallest = 0;
int count = 1;
int num;

[Code] .....

View 1 Replies View Related

C++ :: Program Inputs The Number Of Rows And Columns And Asks For The Entries

Feb 7, 2015

I am writing a program that deals with 2d arrays. The program inputs the number of rows and columns and asks for the entries. When the program run and compiles it works perfectly until it outputs then it gives me a warning.

Here is my code:

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int row1=0,col1=0,i,j;
//int a[row1][col1];
int** a= new int*[row1];

[Code]...

I am learning how to do this before I can move on so it can read a text file of numbers.

Also I am having problems with ////delete [] a[];///// I took it out because it made my code compile and run but when I add it in, it gives me an error:

matrixtesting.cpp|56|error: expected primary-expression before ']' token|

I know this expression is suppose to deallocate the array.

View 7 Replies View Related

C++ :: User Defined Functions - Find Largest And Smallest Number

Nov 16, 2013

I am writing this code, and I every time I run question A, no matter what numbers I put in, I get "larger = 0.

#include <iostream>
using namespace std;
int awesome ();
int best ();
int crazy ();
int main () {
char letter;
int smallestNumber;
int largestNumber;

[Code] .....

View 2 Replies View Related

C :: Drawing Hollow Triangle Given User Input Indicating Number Of Rows

Oct 4, 2014

How to draw a hollow triangle given a user input indicating the number of rows.

Eg:
Number of rows = 4
___*
__*_*
_*___*
*******

My idea was to split up the triangle into three parts (first row, middle part, last row) and I've managed to write some code on printing the first and last row of the triangle

Code:
int main() {
//Declaring the variables.
int rows, position;
//Prompts user to enter number of rows.
printf("Enter the number of rows in the triangle: ");
scanf("%d", &rows);

[Code] .....

What to do so that I can print the middle part of the triangle. All I know is that I need to use loops. I've also been told that drawing a flow chart would work but I really don't know how to even begin with a flow chart then transform it into code.

View 2 Replies View Related

C++ :: Array To Template Class - Finding Largest Number From A Group Of Numbers

Sep 26, 2013

I'm trying to make an array that takes a group of numbers and finds the largest number into a template class.

template<class TYPE>
void Integers(TYPE data) {
int integers[] = {4, 25, 32, 85, 150, 12, 98, 200};
int i = 0;
int Max=integers[0];
for (i=1; i < 8; i++) {

[Code] ....

I'm sure I'm going about it all wrong, but I'm not sure as to get it so that it will accept the arrays input.

View 2 Replies View Related

C/C++ :: Using Print Statement To Print Certain Number Of Spaces

Sep 1, 2014

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
.
.
.

View 2 Replies View Related







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