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

Print Date with c[c programming examples with output]

C programming examples with output

Print Date
Program

#include<stdio.h>
#include<conio.h>
#include<dos.h>
int main()
{
       struct date d;
       getdate(&d);
       printf("Current system date is %d%d/%d,d.da_day,d.da_mon,da_year);
       getch();
       return 0;
}

Local Variables[c programming examples with output]

C programming examples with output

Local Variables
Program

#include<stdio.h>
#include<conio.h>
void fun1();
void fun2();
main()
{
      int t;
      clrscr();
      t=1000;
      fun2();
      printf("\n");
      printf("%d",t);
      getch();
}
     void fun1()
{
     int t;
     t=10;
     printf("%d",t);
}
void fun2()
{
    int t;
    t=100;
    fun1();
    printf("\n");
    printf("%d",t);
}

Output:
10
100
1000