1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ASHA 777 [7]
4 years ago
11

Write a function which will ask users to enter numbers and return the largest number.

Computers and Technology
1 answer:
kherson [118]4 years ago
8 0

Answer:

#include<stdio.h>

int GetLargest()

{

int a[100],n,largest;

printf("Enter number of elements\n");

scanf("%d",&n);

printf("Enter elements\n");

for(int i=0;i<n;i++)

scanf("%d",&a[i]);

i=0;

largest=a[i];

while(i<n)

{

i++

if(a[i]>largest)

largets=a[i];

}

return largest;

}

void main(){

int largest;

largest=GetLargest();

printf("Largest Number is %d",largest);

}

Explanation:

Here we define one function "GetLargest". This function reads n number of elements and finds the largest number among the n elements. Here we took one array and assumed first element is the largest element. if any element of the array is greater that that element we make that as larger and continues.at the end we are getting largest element in the n numbers and returning that to the main.

You might be interested in
A certain string-processing language offers a primitive operation which splits a string into two pieces. Since this operation in
Nostrana [21]

Answer:

Explanation:

First we define define cost(i,j) to be the cost of cutting the string from index i to j. Then,

cost(i,j) = min {length of substring + cost(i,k) + cost(k,j) where i < k < j}

void  s_cut()    

 {

   int l,p;

   int temp=0;

   //ArrayList<Integer> al = new ArrayList<Integer>();

   int al[];

   Scanner s=new Scanner(System.in);

   int table[][];

   ArrayList<Integer> values[][];

   int low=0,high=0;

   int min=0;

   l=s.nextInt();

   p=s.nextInt();

   System.out.println("The values are "+l+"  "+p);

   table= new int[l+1][l+1];

   values= new ArrayList[l+1][l+1];

   al= new int[p];

   for(int i=0;i<p;i++)

   {

       al[i]=s.nextInt();

   }

   for(int i=0;i<=l;i++)

   for(int j=0;j<=l;j++)

       values[i][j]=new ArrayList<Integer>();

   System.out.println();

   for(int i=1;i<=l;i++)

       table[i][i]=0;

   //Arrays.s

   Arrays.sort(al);

   for(int i=0;i<p;i++)

   {

       System.out.print(al[i]+ "  ");

   }

   for(int len=2;len<=l;len++)

   {

       //System.out.println("The length is  "+len);

       for(int i=1,j=i+len-1;j<=l;i++,j++)

       {

           high= min_index(al,j-1);

           low= max_index(al,i);

           System.out.println("Indices are "+low+"  "+high);

           if(low<=high && low!=-1 && high!=-1)

           {

           int cost=Integer.MAX_VALUE;;

           for(int k=low;k<=high;k++)

           {

               //if(al[k]!=j)

               temp=cost;

               cost=Math.min(cost, table[i][al[k]]+table[al[k]+1][j]);

               if(temp!=cost)

               {

                   min=k;  

                   //values[i][j].add(al[k]);

                   //values[i][j].addAll(values[i][al[k]]);

                   //values[i][j].addAll(values[al[k]+1][j]);

                   //values[i][j].addAll(values[i][al[k]]);

               }

               //else

               //cost=0;

           }

           table[i][j]= len+cost;

           values[i][j].add(al[min]);

           //values[i][j].addAll(values[i][al[min]]);

           values[i][j].addAll(values[al[min]+1][j]);

           values[i][j].addAll(values[i][al[min]]);

           }

           else

               table[i][j]=0;

           System.out.println(" values are "+i+"  "+j+"  "+table[i][j]);

       }

   }

   System.out.println(" The minimum cost is "+table[1][l]);

   //temp=values[1][l];

   for(int e: values[1][l])

   {

       System.out.print(e+"-->");

   }

8 0
4 years ago
6. By default,how the table headings are placed. (2 Points)
Dmitrij [34]
They are all bold and what ever else
6 0
3 years ago
The sum of the elements of an integer-valued array recursively calculated as follows: The sum of an array of size 0 is 0; Otherw
Ugo [173]
In what language? Most languages have iterator functions like map in JavaScript that will loop through the elements, making this almost a one liner

sum = 0
arr.map( elem => sum += elem )
8 0
3 years ago
"where is a cookie that is created during a web site visit​ stored?"
tino4ka555 [31]
On the visitor's computer
5 0
3 years ago
The format for the UPDATE command is the word UPDATE, followed by the name of the table to be updated. The next portion of the c
fenix001 [56]

The format for the UPDATE command is the word UPDATE, followed by the name of the table to be updated. The next portion of the command consists of the word <u>SET</u>, followed by the name of the column to be updated, an equals sign, and the new value.​

Explanation:

  • An Update Query is an action query (SQL statement) that changes a set of records according to criteria you specify.
  • The SQL UPDATE Query is used to modify the existing records in a table. You can use the WHERE clause with the UPDATE query to update the selected rows, otherwise all the rows would be affected.
  • Update Queries let you modify the values of a field or fields in a table.

<u>UPDATE Syntax </u>

  • UPDATE table_name
  • SET column1 = value1, column2 = value2, ...
  • WHERE condition;

UPDATE table_name SET column1 = value1, column2 = value2, etc WHERE condition;  

  1. table_name: name of the table
  2. column1: name of first , second, third column....
  3. value1: new value for first, second, third column....
  4. condition: condition to select the rows for which the  
  5. values of columns needs to be updated.

8 0
4 years ago
Other questions:
  • How do you get free Wifi on your phone without paying
    6·1 answer
  • Assign a variable solveEquation with a function expression that has three parameters (x, y, and z) and returns the result of eva
    6·1 answer
  • Cryptanalysis is made more difficult by having shorter keywords.a) trueb) false
    6·1 answer
  • When you build a computer from parts, you usually start by deciding on which processor and motherboard you will use?
    11·1 answer
  • An alarm clock draws 0.5 A of current when connected to a 120 volt circuit. Calculate its resistance.
    10·1 answer
  • Write a print statement that displays a random integer between 5 and 5000. Assume the random library is imported.
    12·1 answer
  • What is the purpose of this parallelogram shape in a flowchart?
    15·1 answer
  • What’s GIGO<br> Please write it in full form
    15·1 answer
  • Gn guys have an Amazing day!
    12·2 answers
  • What would a system unit that is integrated with the display and keyboard would be considered?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!