H.W5,6
H.W5,6
C:202470034
#include<stdio.h>
#include<math.h>
int main(){
while(1){
printf("Prees 1 to go to lab 2\n");
printf("Prees 2 to go to lab 3\n");
printf("Prees 3 to go to lab 4\n");
printf("Prees 4 to go to lab 5,6\n");
int i;
scanf("%d",&i);
switch(i){
case 1:
printf("Lab 2\n");
printf("choose the number of the exercise (1...9)\n");
int j;
scanf("%d",&j);
switch(j){
case 1:
printf("Excercise 1 : The output is error,because the name of the function
is (float)\n");
printf(" Excercise 1: it will print hello , after that will print the
character e , after will print a value\n");
break;
case 2:
printf("Excercise 2\n");
int a;
char r;
printf("Enter a character \n");
scanf("%c",&r);
printf("Enter a number \n");
scanf("%d",&a);
printf("a=%d\t r=%c\n",a,r);
break;
case 3:
printf("Excercise 3\n");
float s1;
float s2;
float s3;
float sum;
float pre ;
printf("Type your drgree of 3 subjects \n");
scanf("%f",&s1);
scanf("%f",&s2);
scanf("%f",&s3);
sum=s1+s2+s3;
printf("the sum of yor degree = %0.2f\n",sum);
pre=sum/3;
printf("the prcentage of yor degree %%%0.2f ", pre);
break;
case 4:
printf("Excercise 4\n");
float s11;
float s22;
float s33;
printf("Type 3 numbers \n");
scanf("%f",&s11);
scanf("%f",&s22);
scanf("%f",&s33);
printf("the subtraction of the numbers = %0.2f-%0.2f-%0.2f=%0.2f\
n",s11,s22,s33,s11-s22-s33);
break;
case 5:
printf("Exercise 5\n");
int x;
printf("type a decimal number to convert it to octal & hexadecimal\n");
scanf("%d",&x);
printf("The hexadecimal you have entered is %X\n",x);
printf("The ocatal you have entered is %o\n",x);
break;
case 6:
printf("Exercise 6\n");
float rrr;
float area;
float cir;
printf("****Enter the radius of the circle****\n");
scanf("%f",&rrr);
area=rrr*rrr*3.14;
cir=2*3.14*rrr;
printf("The area of the circle = %0.2f\n ",area);
printf("The circumference of the circle = %0.2f ",cir);
break;
case 7:
printf("Exercise 7\n");
long double b;
printf("b=%d Bytes\n",sizeof(long double));
break;
case 8:
printf("Exercise 8\n");
float c;
float f;
printf("Enter the temperature in celsius\n");
scanf("%f",&c);
f=(c*1.8)+32;
printf(" the temperature in fahrenheit = %0.2f F\n",f);
break;
case 9:
printf("Exercise 9\n");
int aa,bb;
printf("enter the first number please \n ");
scanf("%d",&aa);
printf("enter the second number please \n ");
scanf("%d",&bb);
int re=(aa*bb)+(3*aa)-bb;
int z=aa+bb+r;
printf("The values are\n r =%d\n z=%d\n",re,z);
printf("\t\tThe end of the program\n");
break;
}
break;
case 2:
printf("Lab 3\n");
printf("choose the number of the exercise (1,2,4)\n");
int yes;
scanf("%d",&yes);
switch(yes){
case 1:
printf("Exercise 1\n");
printf(" Program 1 :The output is nothing\n");
printf(" Program 2 :The output is Hi\n");
printf(" Program 3 :The output is \0 is 0\n");
printf(" Program 3 :The output is 0 is 48 (in Asci code)\n");
printf(" Program 4 :the ouput are a and b the values you have entered , and
c is how many value you have entered so c=2\n");
printf(" Program 5 :The output are 12 and The adderes where the value
stored \n");
break;
case 2:
printf("Exercise 2\n");
printf("the outputs are the sum =10 , and the sub=-4 (beacuse the scanf
can't read valuse with seprated key spaces,so in the first scanf read only 8,2 for
a and b and the remaining values assigned for the second scanf for c and d\n");
break;
case 4:
printf("Exercise 4\n");
double m,x1,z1;
int a1;
printf("Enter the value of m,please\n");
scanf("%lf",&m);
printf("Enter the value of a (integer value), please\n");
scanf("%d",&a1);
x1=((4*m)/8)+3;
z1=(x1*x1)+((10-(4*a1))/5);
double d=x1-z1;
printf("x=%lf\nz=%lf\nd=%lf\n",x1,z1,d);
break;
}
break;
case 3:
printf("Lab 4\n");
printf("choose the number of the exercise (1...8)\n");
int def;
scanf("%d",&def);
switch(def){
case 1:
printf("Exercise 1\n");
printf(" Program 1 :The output is x , beacuse the condition is the value of
x that you have entered and the condtional answer is (x) .\n");
printf(" Program 2 :the output is nothing\n");
printf(" Program 3 :the output is true\n");
printf(" Program 4 :the output is x, unless the user entered a zero value
the output is zero\n");
break;
case 2:
printf("Exercise 2\n");
int nn;
printf("Type a number please\n");
scanf("%d",&nn);
if(nn%2==0){
printf("The number is even \n");
}
else{
printf("The number is odd \n");
}
break;
case 3:
printf("Exercise 3\n");
double as,xs,ys,bs;
printf("To solve this equation , a= (3x+4y^4)/(2x-8)\n");
printf("Type the value of x\n");
scanf("%lf",&xs);
printf("Type the value of y\n");
scanf("%lf",&ys);
bs=2*xs-8;
if(bs!=0){
as=((3*xs)+(4*pow(ys,4)))/(bs);
printf("The answer is a =%0.3lf",as);
}
else{
printf("Error , NO solution !");
}
break;
case 4:
printf("Exercise 4\n");
int mv,nv;
printf("Type the two numbers \n");
scanf("%lf",&mv);
scanf("%d",&nv);
if(nv==mv){
printf("The numbers are equal \n");
}
else{
printf("The numbers are not equal\n");
}
break;
case 5:
printf("Exercise 5\n");
printf("The question is not clear \n");
break;
case 6:
printf("Exercise 6\n");
double af,bf,cf;
printf("Type three numbers\n");
scanf("%lf",&af);
scanf("%lf",&bf);
scanf("%lf",&cf);
if(af>bf&&af>cf){
printf("The maximum value is %0.1lf\n",af);
}
else if(bf>af&&bf>cf){
printf("The maximum value is %0.1lf\n",bf);
}
else if(cf>af&&cf>bf){
printf("The maximum value is %0.1lf\n",cf);
}
break;
case 7:
printf("Question 1\n");
double yg,xg,zg,sg,mg;
printf(" To solve this equa.,m=(y^2+4x-2z^3)*(s^1/3)/y+x-s\n");
printf("Enter the value of x\n");
scanf("%lf",&xg);
printf("Enter the value of y\n");
scanf("%lf",&yg);
printf("Enter the value of z\n");
scanf("%lf",&zg);
printf("Enter the value of s\n");
scanf("%lf",&sg);
mg=(pow(yg,2)+4*xg-2*pow(zg,3))*pow(sg,0.33333)/(yg+xg-sg);
printf("The value of m = %0.2lf\n",mg);
break;
case 8:
printf("Question 3\n");
double xj,zj,yj,bj;
printf("Enter three numbers\n");
scanf("%lf",&xj);
scanf("%lf",&yj);
scanf("%lf",&zj);
bj=(xj+yj+zj)/3;
printf("the middle value is %0.2lf\n",bj);
break;
}
break;
case 4:
printf("Lab 5&6\n");
printf("choose the number of the exercise (1...4)\n");
int ues ;
scanf("%d",&ues);
switch(ues){
case 1:
printf("Exercise 1\n");
int num[6];
int zero = 0;
int posi=0;
int nega=0;
printf("Enter 6 numbers:\n");
for (int w = 0; w < 6; w++) {
printf("Number %d: " ,w+1);
scanf("%d", &num[w]);
if (num[w] == 0) {
zero++;
} else if (num[w] > 0) {
posi++;
} else {
nega++;
}
}
printf("The number of zeros = %d\n", zero);
printf("The number of positive numbers = %d\n", posi);
printf("The number of negative numbers = %d\n", nega);
break;
case 2:
printf("Exercise 2 \n");
int number;
int pri= 1;
printf("Enter a number: ");
scanf("%d", &number);
if (number <= 1) {
pri= 0;
} else {
for (int i = 2; pow(i,2) <= number; i++) {
if (number % i == 0) {
pri = 0;
break;
}
}
}
if (pri) {
printf("%d is a prime number.\n", number);
} else {
printf("%d is not a prime number.\n", number);
}
break;
case 3:
printf("Exercise 3\n");
printf("Choose the program,1,2,3,4\n");
int ti;
scanf("%d", &ti);
switch(ti){
case 1:
printf("Program a\n");
printf("The even numbers are \n");
for(int o=0;o<=10;o++){
if(o%2==0){
printf("%d\n",o);
}
}
break;
case 2:
printf("Program b\n");
int je;
do{
printf("Type positive number\n");
scanf("%d",&je);
printf("The even numbers are \n");
}while(je<0);
for(int yu=0;yu<=je;yu++){
if(yu%2==0)
printf("%d\n",yu);
}
break;
case 3:
printf("Program c\n");
int st;
printf("Type number \n");
scanf("%d",&st);
printf("The even numbers are \n");
if(st>0){
for(int yv=0;yv<=st;yv++){
if(yv%2==0)
printf("%d\n",yv);
}
}
else if(st<0){
for(int vi=st;vi<=0;vi++){
if(vi%-2==0)
printf("%d\n",vi);
}
}
break;
case 4:
printf("Program d\n");
int se;
int de;
printf("Type 2 numbers \n");
scanf("%d",&se);
scanf("%d",&de);
if(de>se){
for(int mm=se;mm<=de;mm++){
if(mm%2==0){
printf("%d \n",mm);
}
}
}
else if(de<se){
for(int mm=de;mm<=se;mm++){
if(mm%2==0){
printf("%d \n",mm);
}
}
}
break;
}
break;
case 4:
printf("Exercise 4\n");
printf("Choose the program ,1,2\n ");
int jg;
scanf("%d",&jg);
switch(jg){
case 1:
printf("Program a\n");
printf("Enter a positive number of the numbers of stars and columns\
n");
int star ;
do{
scanf("%d",&star);
}while(star<=0);
for(int c=1; c<=star; c++){
for(int v=1; v<=c; v++){
printf("*");
}
printf("\n");
}
break;
case 2:
printf("Program b\n");
printf("Enter a positive number of the numbers of stars and columns\n");
int star1 ;
scanf("%d",&star1);
while(star1<=0){
printf("Try Again\n");
scanf("%d",&star1);
}
for(int c=1; c<=star1; c++){
for(int v=1; v<=star1-c; v++){
printf(" ");
}
for(int p=1; p<=c; p++){
printf("*");
}
printf("\n");
}
}
break;
}
break;
}
}