From b3554501edb5424b7a1beed16a84e6763aa3b4c1 Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Tue, 3 Oct 2023 12:16:10 +0100 Subject: [PATCH] c7 --- C7/ex3.c | 13 +++++++++++++ C7/ex4.c | 11 +++++++++++ C7/ex5.c | 15 +++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 C7/ex3.c create mode 100644 C7/ex4.c create mode 100644 C7/ex5.c diff --git a/C7/ex3.c b/C7/ex3.c new file mode 100644 index 0000000..7d6b3bf --- /dev/null +++ b/C7/ex3.c @@ -0,0 +1,13 @@ +#include +#include + +int main() { + float radius, height; + + printf("Enter radius: "); + scanf("%f", &radius); + printf("Enter height: "); + scanf("%f", &height); + + printf("Surface area: %f\n", 2*M_PI*radius*radius + 2*M_PI*radius*height); +} diff --git a/C7/ex4.c b/C7/ex4.c new file mode 100644 index 0000000..92bbf40 --- /dev/null +++ b/C7/ex4.c @@ -0,0 +1,11 @@ +#include + +int main() { + char name[200] = { 0 }; + + printf("What is your name? "); + scanf("%s", name); + + printf("Hello %s\n", name); + +} diff --git a/C7/ex5.c b/C7/ex5.c new file mode 100644 index 0000000..f828e8d --- /dev/null +++ b/C7/ex5.c @@ -0,0 +1,15 @@ +#include + +int main() { + char name[200] = { 0 }; + int age = 0; + + printf("What is your name? "); + scanf("%s", name); + + printf("What is your age? "); + scanf("%ud", &age); + + printf("Hello %s\nYou are %d years old\n", name, age); + +}