i have programe in c but i need to use function and i have no idea how do it can any one help me please and one more thing i cant use loop inside case so it must be out
#include<stdio.h>
#include<stdlib.h>
int main()
{
int row ,n,c,temp,k,count=1;
int input ;
printf("1.UpRight\n");
printf("2.UpSide\n");
printf("3.Triangle\n");
printf("4.Triangle with A\n");
do
{
printf ("Which option will you choose \n") ;
scanf("%d" ,&input);
printf("Enter the number of rows ");
scanf("%d",&n);
switch(input)
{
case 1:
for(c=1;c<=n;c++)
{
for(k=1;k<=c;k++)
{
printf("*");
}
printf("\n");
}
return 0;
break;
case 2:
for(c=n;c>=1;--c)
{
for(k=1;k<=c;++k)
{
printf("*");
}
printf("\n");
}
return 0;
break;
case 3:
temp = n;
for ( row = 1 ; row <= n ; row++ )
{
for ( c = 1 ; c < temp ; c++ )
printf(" ");
temp--;
for ( c = 1 ; c <= 2*row - 1 ; c++ )
printf("*");
printf("\n");
}
return 0;
break;
case 4:
temp = n;
for ( c = 1 ; c <= n ; c++)
{
for( k = 1 ; k < temp ; k++)
printf(" ");
for ( k = 1 ; k <= c ; k++)
{
printf("*");
if ( c > 1 && count < c)
{
printf("A");
count++;
}
}
printf("\n");
temp--;
count = 1;
}
return 0;
break;
default:
printf( "Bad input, quitting!\n" );
break;
}
}
while(true)
}