This is my program code for the main.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include "test.h"
int main()
{
float a,b,c;
int s,g=1;
char ch;
while(g)
{
printf("\nArea of:\n1.Triangle\n2.Square\n3.Circle\n4.Convert letter\nplease choose:");
scanf("%d",&s);
switch(s)
{
case 1:
printf("\nlength:");
scanf("%f",&a);
printf("width:");
scanf("%f",&b);
c=TRI(a,b);
printf("The area is %f",c);
break;
case 2:
printf("\nlength:");
scanf("%f",&a);
printf("width:");
scanf("%f",&b);
c=SQU(a,b);
printf("The area is %f",c);
break;
case 3:
printf("\ndiameter:");
scanf("%f",&a);
c=CIR(a);
printf("The area is %f",c);
break;
case 4:
printf("Upper Case Letter");
scanf("%c",&ch);
ch=CONV(ch);
printf("\nLower Case Version: %c",ch);
break;
default:
printf("YOU PICKED WRONG NUMBER\n");
continue;
}
printf("\ndo you want to use the program again(1=yes/0=no)?");
scanf("%d",&g);
}
return 0;
}
and this is for "test.h"
Code:
#ifndef test_h
#define test_h
#define TRI(a,t) (0.5*a*t)
#define SQU(p,l) (p*l)
#define CIR(r) (0.25*3.14*r*r)
#define CONV(c) (c+32)
#endif
when i compile it, there isn't any warning or error.
but when i run the program, i choose menu 4(Convert Letter),the program skipped the scanf(), so i didn't have the chance to input the letter.
can someone help me please?i don't know what's wrong with my code
*note:don't mind with the Macro abuse. it's just an exercise.