Friday 11 January 2019

Pattern 1 using c[c programming examples with output]

C programming examples with output

Pattern
Program

#include<stdio.h>
#include<conio.h>
void main()
{
      int i,j;
      clrscr();
      for(i=1;i<=5;i++)
      {
          for(j=1;j<=5;j++)
         {
            printf("*");
         }
            printf("\n");
      }
       getch();
}

Output:

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

Monday 7 January 2019

Condensing A Number into Single Digit with c programming[c programming examples with output]

C programming examples with output

Condensing A Number into Single Digit
Program

#include<stdio.h>
#include<conio.h>
main()
{
      int r,i,j,s;
      int a[10];
      long n;
      clrscr();
      printf("Enter any number : ");
      scanf("%ld",&n);
      do
      {
             s=0;i=0;
             while(n>0)
            {
                   r=n%10;
                   a[i]=r;
                   s=s+r;
                   i++;
                   n=n/10;
            }
            --i;
     if(i!=0)
             n=s;
             if(i==0 || i==1)
             {
                   printf("single digit= %d",n);
                   break;
             }
}while(i>0);
getch();
}

Output:
Enter any number:9876543221
((9+8+7+6+5+4+3+2+1)=(45)=(4+5)=9)
single digit=9
Enter any number:32190
single digit=6
Enter any number:1092387456
single digit=9

Best Budget Laptop For Web Developers 2019

Sunday 6 January 2019

Program For Shutdown Computer[c programming examples with output]

C programming examples with output

Shutdown Computer
Program

#include<stdio.h>
#include<stdlib.h>
main()
{
      char ch;
      printf("Do you want to shutdown your computer now(y/n)\n");
      scanf("%c",&ch);
      if(ch=='y' || ch=='Y')
      system("C:\\Windows\\system32\\shutdown/s");
      return 0;
}

Pyramid Of Numbers With C[c programming examples with output]

C programming examples with output

Pyramid Of Numbers
Program

#include<stdio.h>
#include<conio.h>
main()
{
     int rows,t,i,j,k,s;
     clrscr();
     printf("Enter no.of rows to print : ");
     scanf("%d",&rows);
     t=1;
    for(i=1;i<=rows;i++)
    {
        for(j=0;j<(rows-i);j++)
        printf(" ");
        s=(2*i)-1;
            for(k=0;k<s;k++)
       {
            if(t<10)
            printf("%d ",t);
            else
            printf("%d ",t);
            t++;
       }
           printf("\n\n");
    }
    getch();
}

Output:
Enter no, of rows to print:5
                1
             2  3  4
           5 6  7  8  9
       10 11 12 13 14 15 16
    17 18 19 20 21 22 23 24 25