What's new

C language po pa help

zacha

Forum Veteran
Established
Joined
Sep 5, 2021
Posts
778
Reaction
56
Points
686
1653406631493.png
 

Attachments

C:
#include <stdio.h>
#include <ctype.h>

void main()
{
    float length, width;
    char choice;

    do
    {
        printf("Enter length: ");
        scanf("%f", &length);
        printf("Enter width: ");
        scanf("%f", &width);
        printf("Perimeter = %f", (2*length) + (2*width));
        printf("\nWould you like to try again? [y/n]: ");
        scanf(" %c", &choice);
        choice = toupper(choice);

    }while (choice== 'Y');

Yung pangatlong scanf meron talagang space after ng open double quote. It's a workaround sa character input.
 

Similar threads

Back
Top