0% found this document useful (0 votes)
15 views3 pages

NestedFor Kelompok4

The document lists 6 names and then provides code snippets for 3 programming problems - printing a pyramid of stars, printing even numbers in a series, and calculating BMI based on height and weight input.

Uploaded by

jonriozell6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

NestedFor Kelompok4

The document lists 6 names and then provides code snippets for 3 programming problems - printing a pyramid of stars, printing even numbers in a series, and calculating BMI based on height and weight input.

Uploaded by

jonriozell6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Kelompok 4:

- Jonrio Ebenezer Siahaan (132)


- Noel Arizon Panjaitan (057)
- M. Asyraf Rizki (105)
- Divani Modena (027)
- Rafi Fauzan Tsany Lubis (120)
- Jason Sanjaya (066)
1. Bintang (C)
#include <stdio.h>

int main()
{
int n;
printf("Masukkan Jumlah Bintang: ");
scanf("%d", &n);

for (int i = 1; i <= n; i++)


{
for (int j = 1; j <= i; j++)
{
printf("*");
}
printf("\n");
}

for (int i = n; i >= 1; i--)


{
for (int j = 1; j <= i; j++)
{
printf("*");
}
printf("\n");
}
}
2. Deret Genap
#include <iostream>
using namespace std;

int main()
{
int n, hasil = 0;
char con;

cout << "Apakah anda ingin menampilkan deret genap? (Y/T) ";
cin >> con;

while (con == 'Y' || con == 'y')


{
cout << "Masukkan jumlah bilangan genap yang ingin ditampilkan: ";
cin >> n;

for (int i = 2; i <= n * 2; i += 2)


{
cout << i << " ";
hasil = hasil + i;
}

cout << endl;


cout << "Hasil = " << hasil << endl;

cout << "Apakah anda ingin mengulang? (Y/T) ";


cin >> con;
}

return 0;
}
3. BMI
#include <stdio.h>

int main()
{
float tinggi, berat, bmi;
int pilihan;

do
{
printf("===== Kalkulator BMI =====\n");
printf("Masukkan tinggi (meter): ");
scanf("%f", &tinggi);
printf("Masukkan berat (kg): ");
scanf("%f", &berat);

bmi = berat / (tinggi * tinggi);

printf("BMI Anda: %.2f\n", bmi);


if (bmi < 18.5)
{
printf("Anda Kurus\n");
}
else if (bmi >= 18.5 && bmi < 25)
{
printf("Berat Badan Ideal\n");
}
else if (bmi >= 25 && bmi < 30)
{
printf("Anda Kelebihan Berat Badan\n");
}
else
{
printf("Anda Obesitas\n");
}

printf("\nApakah Anda ingin menghitung lagi? (1: Ya, 0: Tidak): ");


scanf("%d", &pilihan);
} while (pilihan != 0);

printf("Terima kasih! Sampai jumpa.\n");

return 0;
}

You might also like