مثال برمجي 9 : Write a C program to print a circle of stars, input = radius

  • 2020-10-29

توصيف

السؤال من كورس ال 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>

لمزيد من التفاصيل يرجى التواصل معي

هل كان المحتوى مفيد؟

التعليقات

لاضافة سؤال أو تعليق على المشاركة يتوجب عليك تسجيل الدخول
تسجيل الدخول
محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...