C වලින් stars පැටන් print කරන්නේ කොහොමද?
Best Answer
-
loops use කරලා කරන විදිය නේද අහන්නේ?
1.
#include<stdio.h> int main() { int i, j, rows; printf("Enter number of rows: "); scanf("%d", &rows); for (i=1; i<=rows; ++i) { for (j=1; j<=i; ++j) { printf("* "); } printf("\n"); } return 0; }
2.
#include<stdio.h> int main() { int i, j, rows; printf("Enter number of rows: "); scanf("%d", &rows); for (i=rows; i>=1; --i) { for (j=1; j<=i; ++j) { printf("* "); } printf("\n"); } return 0; }
3.
#include<stdio.h> int main() { int i, space, rows, k=0; printf("Enter number of rows: "); scanf("%d", &rows); for (i=1; i<=rows; ++i,k=0) { for (space=1; space<=rows-i; ++space) { printf(" "); } while (k!=2*i-1) { printf("* "); ++k; } printf("\n"); } return 0; }
4.
#include<stdio.h> int main() { int rows, i, j, space; printf("Enter number of rows: "); scanf("%d", &rows); for (i=rows; i>=1; --i) { for (space=0; space<rows-i; ++space) printf(" "); for (j=i; j<=2*i-1; ++j) printf("* "); for (j=0; j<i-1; ++j) printf("* "); printf("\n"); } return 0; }
code එක තේරුම් අරන් run කරල බලන්න. errors අවොත් කියන්න.
2
Debug Trace
Info | Could not find file 'oauth2.css' in folder 'oauth2'. |
Notice |
Trying to access array offset on value of type bool #0 /home/xtreabfi/kuppiya/cache/Smarty/compile/vanilla^8d148c5e1b13e8d27851611d20a380b18401257f_0.file.default.master.tpl.php(45): gdn_ErrorHandler(8, 'Trying to acces...', '/home/xtreabfi/...', 45, Array) #1 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_6594354daaee31_19788427(Object(Smarty_Internal_Template)) #2 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template)) #3 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render(Object(Smarty_Internal_Template)) #4 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(232): Smarty_Internal_Template->render(false, 1) #5 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute(Object(Smarty_Internal_Template), NULL, 'vanilla', NULL, 1) #6 /home/xtreabfi/kuppiya/library/core/class.smarty.php(146): Smarty_Internal_TemplateBase->display('/home/xtreabfi/...', NULL, 'vanilla') #7 /home/xtreabfi/kuppiya/library/core/class.controller.php(2232): Gdn_Smarty->render('/home/xtreabfi/...', Object(DiscussionController)) #8 /home/xtreabfi/kuppiya/library/core/class.controller.php(1595): Gdn_Controller->renderMaster() #9 /home/xtreabfi/kuppiya/library/core/class.pluggable.php(217): Gdn_Controller->xRender() #10 /home/xtreabfi/kuppiya/applications/vanilla/controllers/class.discussioncontroller.php(336): Gdn_Pluggable->__call('render', Array) #11 /home/xtreabfi/kuppiya/library/core/class.dispatcher.php(933): DiscussionController->index('16', 'c-\xE0\xB7\x80\xE0\xB6\xBD\xE0\xB7\x92\xE0\xB6\xB1\xE0...', '') #12 /home/xtreabfi/kuppiya/library/core/class.dispatcher.php(335): Gdn_Dispatcher->dispatchController(Object(Gdn_Request), Array) #13 /home/xtreabfi/kuppiya/index.php(29): Gdn_Dispatcher->dispatch() #14 {main} |
Notice |
Trying to access array offset on value of type bool #0 /home/xtreabfi/kuppiya/cache/Smarty/compile/vanilla^8d148c5e1b13e8d27851611d20a380b18401257f_0.file.default.master.tpl.php(125): gdn_ErrorHandler(8, 'Trying to acces...', '/home/xtreabfi/...', 125, Array) #1 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_6594354daaee31_19788427(Object(Smarty_Internal_Template)) #2 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template)) #3 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render(Object(Smarty_Internal_Template)) #4 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(232): Smarty_Internal_Template->render(false, 1) #5 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute(Object(Smarty_Internal_Template), NULL, 'vanilla', NULL, 1) #6 /home/xtreabfi/kuppiya/library/core/class.smarty.php(146): Smarty_Internal_TemplateBase->display('/home/xtreabfi/...', NULL, 'vanilla') #7 /home/xtreabfi/kuppiya/library/core/class.controller.php(2232): Gdn_Smarty->render('/home/xtreabfi/...', Object(DiscussionController)) #8 /home/xtreabfi/kuppiya/library/core/class.controller.php(1595): Gdn_Controller->renderMaster() #9 /home/xtreabfi/kuppiya/library/core/class.pluggable.php(217): Gdn_Controller->xRender() #10 /home/xtreabfi/kuppiya/applications/vanilla/controllers/class.discussioncontroller.php(336): Gdn_Pluggable->__call('render', Array) #11 /home/xtreabfi/kuppiya/library/core/class.dispatcher.php(933): DiscussionController->index('16', 'c-\xE0\xB7\x80\xE0\xB6\xBD\xE0\xB7\x92\xE0\xB6\xB1\xE0...', '') #12 /home/xtreabfi/kuppiya/library/core/class.dispatcher.php(335): Gdn_Dispatcher->dispatchController(Object(Gdn_Request), Array) #13 /home/xtreabfi/kuppiya/index.php(29): Gdn_Dispatcher->dispatch() #14 {main} |
Notice |
Trying to access array offset on value of type bool #0 /home/xtreabfi/kuppiya/cache/Smarty/compile/vanilla^8d148c5e1b13e8d27851611d20a380b18401257f_0.file.default.master.tpl.php(219): gdn_ErrorHandler(8, 'Trying to acces...', '/home/xtreabfi/...', 219, Array) #1 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_6594354daaee31_19788427(Object(Smarty_Internal_Template)) #2 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template)) #3 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render(Object(Smarty_Internal_Template)) #4 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(232): Smarty_Internal_Template->render(false, 1) #5 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute(Object(Smarty_Internal_Template), NULL, 'vanilla', NULL, 1) #6 /home/xtreabfi/kuppiya/library/core/class.smarty.php(146): Smarty_Internal_TemplateBase->display('/home/xtreabfi/...', NULL, 'vanilla') #7 /home/xtreabfi/kuppiya/library/core/class.controller.php(2232): Gdn_Smarty->render('/home/xtreabfi/...', Object(DiscussionController)) #8 /home/xtreabfi/kuppiya/library/core/class.controller.php(1595): Gdn_Controller->renderMaster() #9 /home/xtreabfi/kuppiya/library/core/class.pluggable.php(217): Gdn_Controller->xRender() #10 /home/xtreabfi/kuppiya/applications/vanilla/controllers/class.discussioncontroller.php(336): Gdn_Pluggable->__call('render', Array) #11 /home/xtreabfi/kuppiya/library/core/class.dispatcher.php(933): DiscussionController->index('16', 'c-\xE0\xB7\x80\xE0\xB6\xBD\xE0\xB7\x92\xE0\xB6\xB1\xE0...', '') #12 /home/xtreabfi/kuppiya/library/core/class.dispatcher.php(335): Gdn_Dispatcher->dispatchController(Object(Gdn_Request), Array) #13 /home/xtreabfi/kuppiya/index.php(29): Gdn_Dispatcher->dispatch() #14 {main} |
Notice |
Trying to access array offset on value of type bool #0 /home/xtreabfi/kuppiya/cache/Smarty/compile/vanilla^8d148c5e1b13e8d27851611d20a380b18401257f_0.file.default.master.tpl.php(235): gdn_ErrorHandler(8, 'Trying to acces...', '/home/xtreabfi/...', 235, Array) #1 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_6594354daaee31_19788427(Object(Smarty_Internal_Template)) #2 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template)) #3 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render(Object(Smarty_Internal_Template)) #4 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(232): Smarty_Internal_Template->render(false, 1) #5 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute(Object(Smarty_Internal_Template), NULL, 'vanilla', NULL, 1) #6 /home/xtreabfi/kuppiya/library/core/class.smarty.php(146): Smarty_Internal_TemplateBase->display('/home/xtreabfi/...', NULL, 'vanilla') #7 /home/xtreabfi/kuppiya/library/core/class.controller.php(2232): Gdn_Smarty->render('/home/xtreabfi/...', Object(DiscussionController)) #8 /home/xtreabfi/kuppiya/library/core/class.controller.php(1595): Gdn_Controller->renderMaster() #9 /home/xtreabfi/kuppiya/library/core/class.pluggable.php(217): Gdn_Controller->xRender() #10 /home/xtreabfi/kuppiya/applications/vanilla/controllers/class.discussioncontroller.php(336): Gdn_Pluggable->__call('render', Array) #11 /home/xtreabfi/kuppiya/library/core/class.dispatcher.php(933): DiscussionController->index('16', 'c-\xE0\xB7\x80\xE0\xB6\xBD\xE0\xB7\x92\xE0\xB6\xB1\xE0...', '') #12 /home/xtreabfi/kuppiya/library/core/class.dispatcher.php(335): Gdn_Dispatcher->dispatchController(Object(Gdn_Request), Array) #13 /home/xtreabfi/kuppiya/index.php(29): Gdn_Dispatcher->dispatch() #14 {main} |
Notice |
Undefined index: internal #0 /home/xtreabfi/kuppiya/library/core/class.router.php(70): gdn_ErrorHandler(8, 'Undefined index...', '/home/xtreabfi/...', 70, Array) #1 /home/xtreabfi/kuppiya/library/core/class.theme.php(92): Gdn_Router->getRoute('DefaultControll...') #2 /home/xtreabfi/kuppiya/library/SmartyPlugins/function.breadcrumbs.php(24): Gdn_Theme::breadcrumbs(Array, true, Array) #3 /home/xtreabfi/kuppiya/cache/Smarty/compile/vanilla^8d148c5e1b13e8d27851611d20a380b18401257f_0.file.default.master.tpl.php(332): smarty_function_breadcrumbs(Array, Object(Smarty_Internal_Template)) #4 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_6594354daaee31_19788427(Object(Smarty_Internal_Template)) #5 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template)) #6 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render(Object(Smarty_Internal_Template)) #7 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(232): Smarty_Internal_Template->render(false, 1) #8 /home/xtreabfi/kuppiya/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute(Object(Smarty_Internal_Template), NULL, 'vanilla', NULL, 1) #9 /home/xtreabfi/kuppiya/library/core/class.smarty.php(146): Smarty_Internal_TemplateBase->display('/home/xtreabfi/...', NULL, 'vanilla') #10 /home/xtreabfi/kuppiya/library/core/class.controller.php(2232): Gdn_Smarty->render('/home/xtreabfi/...', Object(DiscussionController)) #11 /home/xtreabfi/kuppiya/library/core/class.controller.php(1595): Gdn_Controller->renderMaster() #12 /home/xtreabfi/kuppiya/library/core/class.pluggable.php(217): Gdn_Controller->xRender() #13 /home/xtreabfi/kuppiya/applications/vanilla/controllers/class.discussioncontroller.php(336): Gdn_Pluggable->__call('render', Array) #14 /home/xtreabfi/kuppiya/library/core/class.dispatcher.php(933): DiscussionController->index('16', 'c-\xE0\xB7\x80\xE0\xB6\xBD\xE0\xB7\x92\xE0\xB6\xB1\xE0...', '') #15 /home/xtreabfi/kuppiya/library/core/class.dispatcher.php(335): Gdn_Dispatcher->dispatchController(Object(Gdn_Request), Array) #16 /home/xtreabfi/kuppiya/index.php(29): Gdn_Dispatcher->dispatch() #17 {main} |
Answers
@Naveen Ranasinghe ස්තුතියි 😊