C++ program code
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,sum,avg;
cout<<"Enter four number:";
cin>>a>>b>>c>>d;
sum=a+b+c+d;
cout<<"\nSum of four number:"<<sum;
avg=sum/4;
cout<<"\nAverage of four number:"<<avg;
getch();
}
JAVA program code
import java.io.*;
class sa
{
public static void main(String []args)
{
int a,b,c,d,sum;
float avg;
try
{
DataInputStream obj=new DataInputStream(System.in);
System.out.println(" Enter four number :" );
a=Integer.parseInt(obj.readLine());
b=Integer.parseInt(obj.readLine());
c=Integer.parseInt(obj.readLine());
d=Integer.parseInt(obj.readLine());
sum=(a+b+c+d);
System.out.println(" Sum of four number:" +sum);
avg=(float)sum/400*100;
System.out.println(" Average of four number: " +avg);
}
catch (Exception e)
{
}
}
}
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,sum,avg;
cout<<"Enter four number:";
cin>>a>>b>>c>>d;
sum=a+b+c+d;
cout<<"\nSum of four number:"<<sum;
avg=sum/4;
cout<<"\nAverage of four number:"<<avg;
getch();
}
JAVA program code
import java.io.*;
class sa
{
public static void main(String []args)
{
int a,b,c,d,sum;
float avg;
try
{
DataInputStream obj=new DataInputStream(System.in);
System.out.println(" Enter four number :" );
a=Integer.parseInt(obj.readLine());
b=Integer.parseInt(obj.readLine());
c=Integer.parseInt(obj.readLine());
d=Integer.parseInt(obj.readLine());
sum=(a+b+c+d);
System.out.println(" Sum of four number:" +sum);
avg=(float)sum/400*100;
System.out.println(" Average of four number: " +avg);
}
catch (Exception e)
{
}
}
}
No comments:
Post a Comment