Knowee
Questions
Features
Study Tools

Write C program to print your name 10 times without using any loop or goto statementsample inputEnter you name :C-Language sample outputC-Language C-Language C-Language C-Language C-Language C-Language C-Language C-Language C-Language C-Language

Question

Write C program to print your name 10 times without using any loop or goto statementsample inputEnter you name :C-Language sample outputC-Language C-Language C-Language C-Language C-Language C-Language C-Language C-Language C-Language C-Language

🧐 Not the exact question you are looking for?Go ask a question

Solution

To print your name 10 times without using any loop or goto statements, you can use recursion. Here is an example of a C program that achieves this:

#include <stdio.h>

void printName(int count) {
    if (count > 0) {
        printf("C-Language ");
        printName(count - 1);
    }
}

int main() {
    int count = 10;
    printName(count);
    return 0;
}

In this program, we define a function printName that takes an integer count as a parameter. Inside the function, we check if count is greater than 0. If it is, we print the name "C-Language" and recursively call the printName function with count decremented by 1. This process continues until count becomes 0, at which point the recursion stops.

In the main function, we initialize the count variable to 10 and then call the printName function with this value. This will print the name "C-Language" 10 times as desired.

Note that recursion is a form of iteration, but it does not use explicit loops or goto statements as specified in the question.

This problem has been solved

Similar Questions

Arun is learning C language. His first program is to print his name in the console with proper spacing and spelling. Help him to achieve the task.Input format :No console input.Output format :The output displays the name as follows: "My Name is Arun."

Choose correct values the java code to print "hello" 10 times  public class Test {        public static void main(String args[])        {                blank ;                for(  blank ;  blank ;  blank )               {                        blank               }  }int i i=1 i<=10 i++ System.out.println("hello");    i%10==0 i<=9 i<10

Write a function that reads your name in lowercase and perform the following operationprints it in uppercaseprints the length of the nameSample Inputsanjay kumarSample OutputSANJAY KUMAR12

write a program to print integer no, from 1 to n where n is the input from the user using do while loop in c language use getch

Given the following:name=["Kim","Bob","Jose","Selena","Chou"]ages=[19,22,21,24,31]Write a program using a for loop that prints:     Kim     19Bob     22Jose    21Selena  24

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.