Answered Questions

  • How do you loop a program to display your name however times you want it to.

    and to display " Hello %s!! Do you want to try again [Y/N]? "

    jyothisudi

    • Aug 6th, 2011

    Here is the code

    Code
    1. #include<stdio.h>
    2. #include<conio.h>
    3. void main()
    4. {
    5. int i,n;
    6. char name[100],ch;
    7. do
    8. {
    9. printf("enter your name");
    10. scanf("%s",&name);
    11. printf("enter the number of times you want to repeat the loop");
    12. scanf("%d",&n);
    13. for(i=0;i<n;i++)
    14. printf("%s",name);
    15. printf("Hello %s!!! do you want to try again Y/N",name);
    16. getchar(ch);
    17. }
    18. while(ch=='Y')
    19. }

  • Declare an array of N pointers

    How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

  • C Pyramid Program

    1 1 2 2 1 2 2 3 3 1 2 2 3 3 4 4 how to create this pyramid using c

    Arun

    • Nov 9th, 2017

    #include "stdio.h" #include "conio.h" void vd_g_printPyramid(int szOfPyramid) { int i; int j; for (i = 0; i < szOfPyramid; i++) { for (j = 0; j <= i; j++) { if (j == 0) { printf("%d", j+1); } else { printf("%d%d", j + 1, j + 1); } } printf(" "); } } int main() { printf(" Hello World"); int i = 0; printf(" Enter size of pyramid"); scanf_s("%d",&i); vd_g_printPyramid(i); _getch(); return 0; }

    Code
    1. #include "stdio.h"
    2. #include "conio.h"
    3.  
    4. void vd_g_printPyramid(int szOfPyramid)
    5. {
    6.         int i;
    7.         int j;
    8.         for (i = 0; i < szOfPyramid; i++)
    9.         {
    10.                 for (j = 0; j <= i; j++)
    11.                 {
    12.                         if (j == 0)
    13.                         {
    14.                                 printf("%d", j+1);
    15.                         }
    16.                         else
    17.                         {
    18.                                 printf("%d%d", j + 1, j + 1);
    19.                         }
    20.                 }
    21.                 printf("
    22. ");
    23.         }
    24. }
    25.  
    26. int main()
    27. {
    28.         printf("
    29. Hello World");
    30.         int i = 0;
    31.         printf("
    32. Enter size of pyramid");
    33.         scanf_s("%d",&i);
    34.         vd_g_printPyramid(i);
    35.        
    36.         _getch();
    37.         return 0;
    38. }

    Andy

    • Nov 4th, 2017

    Code
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. int main() {
    5.         for(int i=1;i<=4;i++){
    6.             for(int j=1;j<=i;j++)
    7.             if(j==1){
    8.                 cout <<j;        
    9.             }
    10.             else
    11.                 cout <<j<<j;
    12.        
    13.             cout<<endl;
    14.         }
    15.        
    16.         return 0;
    17. }

  • how to reverse a string using array?

    shiwang

    • Dec 4th, 2016

    "c #include #include #include #include #include #include #include int main(){ int n,x; scanf("%d",&n); int *arr = malloc(sizeof(int) * n); for(...

  • What is the difference between a string and an array?

    An array is an array of anything. A string is a specific kind of an array with a well-known convention to determine its length. There are two kinds of programming languages: those in which a string is just an array of characters, and those in which it’s a special type. In C, a string is just an array of characters (type char), with one wrinkle: a C string always ends with a NUL character. The “value”...

    RANJIT KUNDU

    • Sep 25th, 2017

    Array is a group of similar data types or strings where string is a single line collection of same data types. Whatever see the examples and explanation, array can be multi dimensional means it can ac...