Jump to content

programming question -- solve this


vaakel_saab

Recommended Posts

  • Six chairs are arranged along a circle. Starting clockwise remove the chair - at count 4 (4th chair in this case). Continue the same process with the fresh count starting from the 5th chair, remove the next chair at count 4, and so on until there is only 1 chair left. Write a function to achieve the result.
  • write a program to PRINTXO(int n)
    • ex: if n= 4

PRINT Below:

xo
ooxx
xxxooo
ooooxxxx

PRINT Below

   xo
  ooxx
 xxxooo
ooooxxxx

Link to comment
Share on other sites

19 minutes ago, vaakel_saab said:
  • Six chairs are arranged along a circle. Starting clockwise remove the chair - at count 4 (4th chair in this case). Continue the same process with the fresh count starting from the 5th chair, remove the next chair at count 4, and so on until there is only 1 chair left. Write a function to achieve the result.
  • write a program to PRINTXO(int n)
    • ex: if n= 4

PRINT Below:

xo
ooxx
xxxooo
ooooxxxx

PRINT Below

   xo
  ooxx
 xxxooo
ooooxxxx

using System;
class HelloWorld {
  static void Main() {
     
    int n=4;
    for(int i=1;i<=n;i++) {
        
        
        for(int j=1;j<=i;j++) {
            Console.Write(i%2==0?"X":"O");
        }
        
        for(int k=1;k<=i;k++) {
            Console.Write(i%2==0?"O":"X");
        }
        
        Console.WriteLine(" ");
    }
  }
}

this is for first question

 

https://onlinegdb.com/zLYQ1wDZX

  • Like 1
Link to comment
Share on other sites

5 minutes ago, Amrita said:

Nenaite interview lo ela evaranna chepte/raste i will def select them. @3$%

eppudu chudaleda adi? Btech computer lab lo output alage chupinche vallu 🤣

Link to comment
Share on other sites

23 minutes ago, vaakel_saab said:
  • Six chairs are arranged along a circle. Starting clockwise remove the chair - at count 4 (4th chair in this case). Continue the same process with the fresh count starting from the 5th chair, remove the next chair at count 4, and so on until there is only 1 chair left. Write a function to achieve the result.
  • write a program to PRINTXO(int n)
    • ex: if n= 4

PRINT Below:

xo
ooxx
xxxooo
ooooxxxx

PRINT Below

   xo
  ooxx
 xxxooo
ooooxxxx

this is for second question....

 

using System;
class HelloWorld {
  static void Main() {
     
    int n=4;
    for(int i=1;i<=n;i++) {
        
        for(int m=n;m>=i;m--) {
            Console.Write(" ");
        }
        for(int j=1;j<=i;j++) {
            Console.Write(i%2==0?"X":"O");
        }
        
        for(int k=1;k<=i;k++) {
            Console.Write(i%2==0?"O":"X");
        }
        
        Console.WriteLine(" ");
    }
  }
}

https://onlinegdb.com/DfLt1nEfhi

  • Like 1
Link to comment
Share on other sites

9 minutes ago, dasari4kntr said:

using System;
class HelloWorld {
  static void Main() {
     
    int n=4;
    for(int i=1;i<=n;i++) {
        
        
        for(int j=1;j<=i;j++) {
            Console.Write(i%2==0?"X":"O");
        }
        
        for(int k=1;k<=i;k++) {
            Console.Write(i%2==0?"O":"X");
        }
        
        Console.WriteLine(" ");
    }
  }
}

this is for first question

Thanks ba

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...