current position:Home>What's wrong with this? Please answer it by experts

What's wrong with this? Please answer it by experts

2022-01-26 21:47:18 CSDN Q & A

#include <stdio.h>#include <stdlib.h>#include <conio.h>#include <windows.h>#include <time.h>int main(){ int a,b,c,d,i,f,g; char q; a=0; b=0; c=0; d=0; i=0; f=0; g=0; printf(" Calculated area \n"); printf(" 1: Square 2: Rectangle 3: triangle 4: parallelogram 5: trapezoid \n"); printf(" Input 1~5 It works , The other is invalid ") q=getch(); while (q=5) { system("cls"); printf(" Top and bottom Bottom high Go blank first , Writing number , Press enter after writing "); scanf("3%d",&a,&b,&c); i=(a+b)c/2; printf("%d",i); system("pause"); return 0; } while (q=4) { system("cls"); printf(" At the end of high Go blank first , Writing number , Press enter after writing "); scanf("%d%d",&a,&b); i=ab; printf("%d",i); system("pause"); return 0;} while (q=3) { system("cls"); printf(" At the end of high Go blank first , Writing number , Press enter after writing "); scanf("%d%d",&a,&b); i=ab/2; printf("%d",i);system("pause"); return 0; } while (q=2) {system("cls"); printf(" Long wide Go blank first , Writing number , Press enter after writing "); scanf("%d%d",&a,&b); i=ab; printf("%d",i); system("pause"); return 0; } while (q=1) { system("cls"); printf(" Long Go blank first , Writing number , Press enter after writing "); scanf("%d",&a); i=aa; printf("%d",i); system("pause"); return 0; } }




Refer to the answer 1:
#include <stdio.h>#include <stdlib.h>#include <conio.h>#include <windows.h>#include <time.h>int main(){    int a,b,c,d,i,f,g;    char q;    a=0; b=0; c=0; d=0; i=0; f=0; g=0;     printf("  Calculated area \n");     printf(" 1: Square  2: Rectangle  3: triangle  4: parallelogram  5: trapezoid \n");     printf("  Input 1~5 It works , The other is invalid ");    q=getchar();     getchar();    while (q=='5') {        system("cls");         printf(" Top and bottom   Bottom   high   Go blank first , Writing number , Press enter after writing ");         scanf("3%d",&a,&b,&c);         i=(a+b)*c/2;         printf("%d",i);         system("pause");        return 0;    }    while (q=='4') {        system("cls");         printf(" At the end of   high   Go blank first , Writing number , Press enter after writing ");         scanf("%d%d",&a,&b);         i=a*b;         printf("%d",i);         system("pause");         return 0;    }    while (q=='3') {         system("cls");        printf(" At the end of   high   Go blank first , Writing number , Press enter after writing ");         scanf("%d%d",&a,&b);         i=a*b/2;         printf("%d",i);        system("pause");         return 0;     }     while (q=='2') {        system("cls");         printf(" Long   wide   Go blank first , Writing number , Press enter after writing ");         scanf("%d%d",&a,&b);        i=a*b;         printf("%d",i);         system("pause");         return 0;     }     while (q=='1') {         system("cls");         printf(" Long   Go blank first , Writing number , Press enter after writing ");         scanf("%d",&a);         i=a*a;         printf("%d",i);         system("pause");         return 0;     } }



Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201262147171110.html

Random recommended