• Streams & Subjects

    Streams & Subjects

    Get detailed description of each and every topic with proper examples including text, images and videos.

  • Latest Technologies

    Latest Technologies

    Know more about the latest and new emerging technologies and boost your knowledge.

  • Programming

    Programming

    Don't learn just codes and syntax, instead learn the best and efficient way of coding.

  • Technologies

    New Technologies

    Get instant and relevant updates of the latest emerging technologies of lots of streams including web, clouds, virtualization, etc.

  • Freewares

    Freewares

    Download free trials and freewares of various fields and check out their efficiency before buying.

  • Multimedia

    Multimedia

    Learn techniques to design amazing and creative multimedia designs and characters including 2D & 3D layout with rendering.

Showing posts with label C Programs. Show all posts
Showing posts with label C Programs. Show all posts

Program in C to print numeric triangle



Write a C program to print the following number rectangle:

1333
2222
3331

Solution:

/*c program for print number rectangle pyramid*/

#include<stdio.h>
int main()
{
            int num,n,r,c,k;
            printf("Enter no. of rows: ");
            scanf("%d", &num);
            n=num;
            for(r=1; r<=num; r++,n--)
            {
                        for(c=1; c<=r; c++)
                                    printf("%d",r);
                        for(k=1; k<=n; k++)
                                    printf("%d",n);
                        printf("\n");
            }
            return 0;
}


Read more

Program in C to print numeric triangle



Write a C program to print the following triangle using function.
 1
 2 3
 4 5 6
 7 8 9 1
 2 3 4 5 6

Solution:
/*C program for number pyramid using function*/

#include<stdio.h>
void pyramid(int);
int main()
{
            int num;
            printf("Enter the number of rows : ");
            scanf("%d", &num);
            pyramid(num);
            return 0;
}
void pyramid(int n)
{
            int r,c,x=1,y=1;
            for(r=1; r<=n; r++)
            {
                        for(c=1; c<=r; c++,x++)
                        {
                                    if(x<=9)
                                                printf(" %d",x);
                                    else
                                    {
                                                printf(" %d",y);
                                                y++;
                                    }
                        }
                        printf("\n");
            }
}


Read more

Program in C to print the triangle using function



Write a program in C to print the following triangle using function
1
2 3
4 5 6
7 8 9 1
2 3 4 5 6

Solution:

/*C program for number pyramid using function*/
#include<stdio.h>
void pyramid(int );
int main()
{
            int num;
            printf("Enter the number of rows : ");
            scanf("%d", &num);
            pyramid(num);
            return 0;
}

void pyramid(int n)
{
            int r,c,x=1,y=1;
            for(r=1; r<=n; r++)
            {
                        for(c=1; c<=r; c++,x++)
                        {
                                    if(x<=9)
                                                printf(" %d",x);
                                    else
                                    {
                                                printf(" %d",y);
                                                y++;
                                    }
                        }
                        printf("\n");
            }
}



Read more

Program in C to print the star pyramid structure

Write a program in C to print the following star pyramid structure: 

*********
*******
*****
***


Solution:
#include<stdio.h>
intmain()
{
intn=9,r,c;
for(r=5; r>=1; r--,n=n-2)
{
for(c=1; c<=n; c++)
printf("*");
printf("\n");
}
return 0;
}



Read more