Program: like us on facebook
#include<stdio.h>
int main()
{
char ch;
char a[20][20]; /* 2D array declaration */
int main()
{
char ch;
char a[20][20]; /* 2D array declaration */
printf("enter i or I");
scanf(" %c",&ch); /* read input */
printf("\n\n\n"); /* for new lines (optional) */
int i,j,k;
switch(ch)
{
case 'I':
case 'i':
for(i=0;i<8;i++){ /* for every row */
if(i==0||i==7){ /* if row is either 1st or last */
for(j=0;j<11;j++) /* for every column */
printf("\x03"); /* print love symbol */
printf("\n");
}
else{ /* if row is neither 1st nor last */
printf(" \x03\n");
}
}
printf("\n\n\n"); /* after printing I, new lines */
case 'L': for(i=0;i<10;i++) /* 1st store love symbol in all element spaces */
{
for(j=0;j<12;j++){
a[i][j]='\x03';
}
scanf(" %c",&ch); /* read input */
printf("\n\n\n"); /* for new lines (optional) */
int i,j,k;
switch(ch)
{
case 'I':
case 'i':
for(i=0;i<8;i++){ /* for every row */
if(i==0||i==7){ /* if row is either 1st or last */
for(j=0;j<11;j++) /* for every column */
printf("\x03"); /* print love symbol */
printf("\n");
}
else{ /* if row is neither 1st nor last */
printf(" \x03\n");
}
}
printf("\n\n\n"); /* after printing I, new lines */
case 'L': for(i=0;i<10;i++) /* 1st store love symbol in all element spaces */
{
for(j=0;j<12;j++){
a[i][j]='\x03';
}
}
for(i=0;i<2;i++) /* replace some of the above symbols with white spaces */
a[i][5]=' '; /* top space */
for(i=2;i<10;i++) /* left spaces */
{
for(j=0;j<i-1;j++)
a[i][j]=' ';
}
for(i=2;i<10;i++){ /* right spaces */
for(j=10;j>11-i;j--)
a[i][j]=' ';
}
for(i=0;i<10;i++){ /* print */
for(j=0;j<11;j++)
printf("%c",a[i][j]);
printf("\n");
}
case 'U': for(i=0;i<8;i++){ /* for every row */
if(i!=7) /* if its not last row */
printf("\x03 \x03");
else{ /* if its last row */
for(i=0;i<2;i++) /* replace some of the above symbols with white spaces */
a[i][5]=' '; /* top space */
for(i=2;i<10;i++) /* left spaces */
{
for(j=0;j<i-1;j++)
a[i][j]=' ';
}
for(i=2;i<10;i++){ /* right spaces */
for(j=10;j>11-i;j--)
a[i][j]=' ';
}
for(i=0;i<10;i++){ /* print */
for(j=0;j<11;j++)
printf("%c",a[i][j]);
printf("\n");
}
case 'U': for(i=0;i<8;i++){ /* for every row */
if(i!=7) /* if its not last row */
printf("\x03 \x03");
else{ /* if its last row */
for(j=0;j<11;j++)
printf("\x03");
printf("\x03");
}
printf("\n");
}
}
return 0;
}
printf("\n");
}
}
return 0;
}
Note: Purposefully I have not put break statements and default statement in the switch for user friendly. You can add them at appropriate places.
Input: Give input i or I.
9 comments:
Write a C program to print all prime number between 1 to 300 using for loop.
Code of given problem:
int main()
{
int a,b;
printf("List of prime numbers between 1 to 300:\n");
printf("%d\t",a=2);
for(a=1;a<=300;a++)
{
for(b=2;b<=a-1;b++)
if(a%b==0)
break;
else if(b==a-1)
{
printf("%d\t",a);
}
}
return 0;
}
Very informative blog!
Please take some time to visit my blog @
Top 10 programming examples in C
Thanks!
Out put is not comming in geometric program
Wow
I
Teach me please
Thanks to sharing with us
buy diazepam online UK
bensedin 10mg UK
Sleeping Pill UK
op
Welcome to our FDA-approved online pharmacy (Cheap Sleeping Tablet)! Our pharmacy is regarded s the best sleeping pills UK supplier of licensed medications for the treatment of insomnia.
https://cheapsleepingtablet.com/
Post a Comment