Professional Documents
Culture Documents
Work Shop2
Work Shop2
#include <iostream>
using namespace std;
void main()
{
int a,b,c,d,e,sum;
float arg =0;
cin>>a>>b>>c>>d>>e;
sum =a+b+c+d+e;
avg=sum/5;
return 0;
}
:Question 2
Write a C++ program that accepts four
integer from the user and prints “equal” if
all four are equal, and “not equal”
.otherwise
#include <iostream>
using namespace std;
void main()
{
int a,b,c,d,;
cout << "enter four number " ;
cin>>a>>b>>c>>d;
} return 0;
}
Question 4
Write a C++ program to get a number from
the user and print whether it is positive or
negative.
#include <iostream>
int main()
else //
if not
}
Question 5
Write a C++ program to take three
numbers from the user and print the
greatest number.
#include <iostream>
using namespace std;
int main()
{
int n1,n2,n3;
//variable declaration cout<<"enter first number:";
cin>>n1;
cout<<"enter second number:";
cin>>n2;
cout<<"enter third number:";
cin>>n3;
if (n1>n2&&n1>n3)
//check whether n1 is greatest than n2 and n3
{
cout<<"greatest number is:"<<n1;
//if yes print this
}
else if(n2>n1&&n2>n3) //check whether n2 is
greatest than n1 and n3
{
cout<<"greatest number is:"<<n2;
//if yes print this
}
else //if not
{
cout<<"greatest number is:"<<n3;
//print this
}
return 0;
}