Pages

Showing posts with label program. Show all posts
Showing posts with label program. Show all posts

Saturday, April 12, 2014

Number Triangle Program

Q. Write a C program to print the following number triangle design:

1
232
34543
4567654

Ans.

/*c program for number triangle design*/
#include<stdio.h>
int main()
{

 int num,r,c,s,t,q;
 printf("Enter any number : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++)
 {
  for(c=r, s=r; c>=1; c--,s++)
     printf("%d", s);
  for(q=r-1,t=s-2; q>=1; q--,t--)
     printf("%d", t);
  printf("
"
);

 }
 return 0;
}

The output of above program would be:


Output of number pyramid C program
Figure: Screen shot for number pyramid C program

Read More..

Tuesday, April 8, 2014

PROGRAM FOR SHUTDOWN TIMER

#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<stdlib.h>
void main()
{
int t,i,s;
clrscr();
printf("enter the time in sec:");
scanf("%d",&t);

for(i=0;i<t;i++)
{
delay(1000);
}
s=system("TSSHUTDN.EXE 0 /DELAY:0 /POWERDOWN");
printf("%d",s);
//printf("Shutting down............");
}

Read More..