Computer Science, asked by huyamloai, 4 months ago

1- Define two functions to print the maximum and the minimum number respectively among three numbers.
2-Define a function to check if the string has a vowel or not
3-Create two arrays then check if they contain the same element
4-Write a function to make a summation for all elements in an integer array

Answers

Answered by manishadhiman31
2

int min(int a, int b) { return ((a <= b) ? a : b); } 

int max(int a, int b) { return ((a >= b) ? a : b); } 

Then for three numbers you can write

int minval = min(a, min(b, c)); 

int maxval = max(a, max(b, c)); 

def vowel_character(c): if c in 'aeiou': print("contains a vowel") return True else: print("contains no vowel") return False

And it almost works like I want it to. With the asserts here however

for c in assert vowel_character(c) for c in 'bcdfghjklmnpqrstvxz': assert not vowel_character(c)

it returns

contains a vowel contains a vowel contains no vowel

var array1 = [2, 4]; var array2 = [4, 2]; //It cames from the user button clicks, so it might be disordered. array1.sort(); //Sorts both Ajax and user info. array2.sort(); if (array1==array2) { doSomething(); }else{ doAnotherThing(); }

#include <conio.h>

 

int main()

{

    int a[1000],i,n,sum=0;

  

    printf("Enter size of the array : ");

    scanf("%d",&n);

    printf("Enter elements in array : ");

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

    {

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

    }

    

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

    {

        

        sum+=a[i];

    }

     printf("sum of array is : %d",sum);

 

    return 0;

}

Answered by govindapatro2000
0

Answer:import java.util.*;

public class maxmin {

   public static int maxnumber(int x,int y,int z){

       if(x>y && x>z){

        return x;  

       }

       else if(y>z && y>x){

           return y;

       }

       else{

           return z;

       }

   }

   public static int minnumber(int x,int y,int z){

       if(x<y && x<z){

           return x;

       }

       else if(y<x && y<z){

           return y;

       }

       else {

           return z;

       }

       

   }

   public static void main(String args[]){

       Scanner sc = new Scanner(System.in);

       int x = sc.nextInt();

       int y = sc.nextInt();

       int z = sc.nextInt();

       System.out.println("largest number is : " +maxnumber(x, y, z));

       System.out.println("Smallest number is : "+minnumber(x, y, z));

   }

}

Explanation:

Similar questions