Document From Mohamed Fouad
Document From Mohamed Fouad
Quiestion [1]1
Quiestion [1]2
The Output is
0-24
25-49
50-49
75-99
100-124
125-149
150-174
175-200
Quiestion [1]3
#include<iostream>
using namespace std;
int main()
{
int n, t=0, counter = 1, z, fact = 1;
do {
cout << "enter positive number \n";
cin >> n;
int main()
char a;
cin >> a;
switch (a) {
return 0;
Quiestion [2]2
#include<iostream>
using namespace std;
int main()
{
int counterm = 0, summ = 0, a[4], counterf = 0, sumf = 0;
char b[4];
for (int i = 0; i < 4; i++) {
cout << "enter gender then enter GPA\n";
cin >> b[i] >> a[i];
if (b[i] == 'm')
{
summ += a[i];
counterm++;
}
else if (b[i] == 'f')
{
sumf += a[i];
counterf++;
}
}
cout << "number of male is = " << counterm << endl;
cout << "avg of male gpa is = " << summ / counterm << endl;
cout << "number of female is = " << counterf << endl;
cout << "avg of female gpa is = " << sumf / counterf << endl;
}
Quiestion [2]3
#include<iostream>
using namespace std;
int main()
{
int i = 1;
while (i<=5)
{
int j = 1;
while (j <= 5)
{
cout << " " << i * j;
j++;
}
cout << endl;
i++;
}
}
Quiestion [3]
Quiestion [3]A
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int x[1000], y[1000], sumx = 0, sumy = 0, n, i, avgx, avgy, sumxpow = 0, sumypow = 0 ;
float z;
do {
cout << "enter value of n betweek 20,1000 \n";
cin >> n;
} while (n < 20 || n>1000);
cout << "enter value of Array x Then Array y \n";
for (i = 0; i < n; i++)
{
cin >> x[i] >> y[i];
sumx += x[i];
sumy += y[i];
}
avgx = sumx / n;
avgy = sumy / n;
sumx = 0;
sumy = 0;
for (i = 0; i < n; i++)
{
sumx += x[i] - avgx;
sumy += y[i] - avgy;
Output
sum =18
sum =34
sum =64
sum =91
sum =97
sum =94
Quiestion [4]
Quiestion [4]1
#include<iostream>
#include<math.h>
using namespace std;
Cout<<”E=”<<E<<endl;
Quiestion [4]2
#include<iostream>
#include<math.h>
using namespace std;
}
int getcount(int a[], int n , int avg) {
float count = 0.0;
for (int i = 0; i < n; i++) {
if (a[i] > avg) break;
count++;
}
return count;
}
int main()
{
int a[10] = { 1,2,3,4,5,6,7,8,9,10 };
cout << "average =" << getaverage(a, 10) << endl;
cout << "min =" << getmin(a, 10) << endl;
cout << "count =" << getcount(a, 10 , getaverage(a, 10)) << endl;