About Me

My photo
gandhinagar, gujarat, India
hi.. friends i'am student of kv crpf gandhinagar..and i would like to spread my view and thinking on computer..this blog is for not only those who wants to get knowledge.

Saturday 7 May 2011

optional programs in C language


#include<conio.h>
#include<stdio.h>
int i,j;
void first();
void second();
void main()
{
char ch;
printf("\n\n\n\t\tpress 1 for first program:\n\n\t\t");
printf("press 2 for first program:\n\n\n\t\t");
ch=getch();
switch(ch)
{
case'1':
first();
break;
case '2':
second();
break;
}

}


void first()
{

for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{

printf("%d",j);
}
printf("\n");
}

}

void second()
{
  for(i=1;i<=5;i++)

{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("1");
}
}

0 comments:

Post a Comment