Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Input: Two even integers. Output: Average of those numbers.

0 votes
asked Aug 4, 2019 by athira (190 points)

Input: Two even integers.
Output: Average of those numbers. 

8 Answers

0 votes
answered Aug 5, 2019 by lata (220 points)
#include<stdio.h>
void main()
{
    int a, b,c;
    scanf("%d %d",&a,&b);
    if(a%2==0&&b%2==0)
    {
        c=(a+b)/2;
        printf("%d",c);
        
    }
}
commented Aug 8, 2019 by Utkarsh Gupta (140 points)
average of odd number is also possible
0 votes
answered Aug 6, 2019 by Gattu
# in python

n = int(input("please enter any even number :"))

m = int(input("please enter any even number :"))

if (((n % 2) == 0 ) and ((m % 2) == 0)):

    print(" average of numbers is : {0}".format((n+m)/2))

else:

    print("enter even numbers")
0 votes
answered Aug 8, 2019 by Abdulelah (150 points)
for (c++)

#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a+b)/2;
    return 0;
}
0 votes
answered Aug 8, 2019 by Utkarsh Gupta (140 points)

#include <stdio.h>

int main(void)

{

   int a,b;

 float c;

 printf("Enter two numbers")

  scanf("%d%d',&a,&b);

 c=(float)(a+b)/2;

printf("average of two integers numbers is=%d",c);

return 0;

}

0 votes
answered Aug 8, 2019 by anonymous
#include<stdio.h>

int main()

{

  int a,b;

scanf("%d%d",&a,&b);

printf("average=%d",(a+b)/2);

return 0;

}
0 votes
answered Aug 10, 2019 by anonymous
a = input().split(' ')
print((int(a[0]) + int(a[1]))/2)

#Example Input: 2 5

#output = 3.5
+1 vote
answered Aug 11, 2019 by anonymous
//in C

#include<stdio.h>
void main()
{   
    int a,b,c;
    printf("Enter the two even numbers:");
    scanf("%d,%d",&a,&b);
    c=(a+b)/2;
    if(a%2==0&&b%2==0)printf("%d",c);
    else printf("Please enter even numbers");
    
}
0 votes
answered Aug 11, 2019 by keerthana (180 points)
import java.util.Scanner;
public class Main
{
    int c;
    void even(int a,int b)
    {
        if(a%2==0&&b%2==0)
        {
        c=(a+b)/2;
        System.out.print(c);
        }
        else
        {
        System.out.print("not a even num");
        }
    }
    public static void main(String[] args) {
        int a,b;
        Scanner sc=new Scanner(System.in);
        a=sc.nextInt();
        b=sc.nextInt();
        Main k=new Main();
        k.even(a,b);
    }
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...