مثال برمجي 9 : Write a C program to print a circle of stars, input = radius
-
2020-04-15
- | drMohammedAbdElrahem
- | مشاهدات: 824
السؤال من كورس ال Programming الخاص بي
Write a C program to print a circle of stars, input = radius .
0
الحل مرفق
/**************************************************************************************************
Name : ex24.c
Author : Mohamed Elsayed
Description : Assignment 1 - Ex 24
**************************************************************************************************/
#include
#include
// function to print circle pattern
void printPattern(int radius) {
// dist represents distance to the center
float dist;
// for horizontal movement
for (int i = 0; i <= 2 * radius; i++) {
// for vertical movement
for (int j = 0; j <= 2 * radius; j++) {
dist = sqrt((i - radius) * (i - radius) + (j - radius) * (j - radius));
// dist should be in the range (radius - 0.5)
// and (radius + 0.5) to print stars(*)
if (dist > radius - 0.5 && dist < radius xss=removed>
لمزيد من التفاصيل يرجى التواصل معي
هذه المادة الدراسية هي ضمن مكتبة
أمثلة برامج Cقد يهمك أيضاً بمادة
التعليقات
لا يوجد تعليقات
لاضافة سؤال او تعليق على المشاركة يتوجب عليك تسجيل الدخول
تسجيل الدخول
تسجيل الدخول