View all courses
This Course is designed for the aspiring Web Designers and Developers with a need to understand the HTML in enough detail along with its simple overview, and practical examples.
Read more
CSS is used to control the style of a web document in a simple and easy way.This tutorial will help both students as well as professionals who want to make their websites.
JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications. It is complimentary to and integrated with Java.
This tutorial is designed for software programmers who wants to learn the basics of jQuery and its programming concepts in simple and easy ways. This tutorial will give you enough understanding on components of jQuery with suitable examples.
AJAX, is a web development technique for creating interactive web applications. If you know JavaScript, HTML, CSS, and XML, then you need to spend just one hour to start with AJAX.
HTML5 is the latest and most enhanced version of HTML.Technically, HTML is not a programming language, but rather a mark up language.This tutorial has been designed for beginners in HTML5 providing the basic to advanced concepts of the subject.
PHP (Hypertext Preprocessor), it is extensively used by developers for programming and development. PHP has lots of benefits and easy to learn so it is the first choice of developers and programmer.
Many PHP programming courses cover the basics or a specific concept. Our Advanced PHP Development course gives you the concepts, features, tools, and practical advice to use them together to build performant, secure, scalable, and reliable web applications.
In this tutorial we will provide you with detailed instructions on how to use WordPress to create and manage your site. WordPress can be used for both simple and complex websites. In our WordPress tutorial we have tried to cover all the basics and few advanced topics.
This tutorial has been prepared for developers who would like to learn the art of developing websites using CodeIgniter. It provides a complete understanding of this framework.
Zend Framework 1 is an open source framework for developing web applications and services using PHP 5.3+. Zend Framework 1 uses 100% object-oriented code and utilises most of the new features of PHP 5.3.
Zend Framework 2 is an open source Module based framework for developing web applications and services using PHP 5.5+. Zend Framework 1 uses 100% object-oriented code and utilises most of the new features of PHP 5.5
The Language Which does not need any prior knowledge of Programming and Easy to learn .Python is Object-oriented ,interpreted and Server side Scripting language .
In Advance concept After learning Core Python We will use Python to create Desktop Application, Web Application, Sockets Programming , Multithread Programming. Since its An Open source Language its free of Cost
Ruby is server side, dynamic, reflective, object-oriented, general-purpose programming language. Ruby is "an interpreted scripting language for quick and easy object-oriented programming"
Ruby on Rails, or simply Rails, is a web application frameworkwritten in Ruby under the MIT License. Rails is a model–view–controller (MVC) framework, providing default structures for a database, a web service, and web pages.
If you have any confusion then you can ask our experts.Our experts will guide you properly.
We are looking you if you are looking guidance for web design and development. Apply online.
Contact us
< Predict the output on loop Last >
Q1 Print a right-angled triangle
Output * * * * * * * * * * * * * * *
Solution
#include <stdio.h> int main() { int i, j, n = 5; for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { printf("* "); } printf("\n"); } return 0; } Explanation: The outer loop controls the rows, and the inner loop prints stars equal to the current row number. Q2. Print an inverted right-angled triangle Output * * * * * * * * * * * * * * *
#include <stdio.h> int main() { int i, j, n = 5; for (i = n; i >= 1; i--) { for (j = 1; j <= i; j++) { printf("* "); } printf("\n"); } return 0; } Explanation: The outer loop decreases from 5 to 1, so each new row contains one fewer star.
Q3. Print a pyramid pattern Output * * * * * * * * * * * * * * *
#include <stdio.h> int main() { int i, j, n = 5; for (i = 1; i <= n; i++) { for (j = 1; j <= n - i; j++) { printf(" "); } for (j = 1; j <= i; j++) { printf("* "); } printf("\n"); } return 0; } Explanation: The first inner loop prints leading spaces. The second inner loop prints stars.
Q4. Print an inverted pyramid Output * * * * * * * * * * * * * * * #include <stdio.h> int main() { int i, j, n = 5; for (i = n; i >= 1; i--) { for (j = 1; j <= n - i; j++) { printf(" "); } for (j = 1; j <= i; j++) { printf("* "); } printf("\n"); } return 0; } Explanation: As the number of stars decreases, the number of leading spaces increases.
Q5. Print a number triangle Output 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
#include <stdio.h> int main() { int i, j, n = 5; for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { printf("%d ", j); } printf("\n"); } return 0; } Explanation: The inner loop prints numbers from 1 up to the current row number.
Q6. Print Floyd's Triangle Output 1 2 3 4 5 6 7 8 9 10
#include <stdio.h> int main() { int i, j, n = 4; int num = 1; for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { printf("%d ", num); num++; } printf("\n"); } return 0; } Explanation: The variable num increases after every number printed, continuing the sequence across rows.
Q7. Print a diamond shape Output * * * * * * * * * * * * * * * * * * * * * * * * *
#include <stdio.h> int main() { int i, j, n = 5; // Upper part for (i = 1; i <= n; i++) { for (j = 1; j <= n - i; j++) { printf(" "); } for (j = 1; j <= i; j++) { printf("* "); } printf("\n"); } // Lower part for (i = n - 1; i >= 1; i--) { for (j = 1; j <= n - i; j++) { printf(" "); } for (j = 1; j <= i; j++) { printf("* "); } printf("\n"); } return 0; } Explanation: The upper part increases the number of stars from 1 to 5. The lower part decreases them from 4 to 1.
Q8. Print a square of numbers Output 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 #include <stdio.h> int main() { int i, j, n = 5; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { printf("%d ", i); } printf("\n"); } return 0; } Explanation: The outer loop determines the number printed in each row. The inner loop repeats that number five times.
Q9. Print a hollow square Output * * * * * * * * * * * * * * * *
#include <stdio.h> int main() { int i, j, n = 5; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (i == 1 || i == n || j == 1 || j == n) { printf("* "); } else { printf(" "); } } printf("\n"); } return 0; } Explanation: A star is printed if the current position is on the first row, last row, first column, or last column. Otherwise, spaces are printed.
Q10. Print a checkerboard-style pattern Output * * * * * * * * * * * * * * * * #include <stdio.h> int main() { int i, n = 4; for (i = 0; i < n; i++) { if (i % 2 == 0) { printf("* * * *\n"); } else { printf(" * * * *\n"); } } return 0; }
{{questionlistdata.blog_question_description}}
{{answer.blog_answer_description }}