ABCDEFGFEDCBA
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A
C Program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include<stdio.h> int main() { int i,j,k,l,m; for(i=0;i<=6;i++) { for(k=65;k<=71-i;k++) printf("%c",k); for(j=1;j<=i*2-1;j++) printf(" "); for(l=71-i;l>=65;l--) if(l!=71) printf("%c",l); printf("n"); } return 0; } |
C++ Program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include<iostream> using namespace std; int main() { int i,j,k,l,m; for(i=0;i<=6;i++) { for(k=65;k<=71-i;k++) cout<<(char)k; //typecasting integer to character for(j=1;j<=i*2-1;j++) cout<<" "; for(l=71-i;l>=65;l--) if(l!=71) cout<<(char)l; cout<<"n"; } return 0; } |
Comment below if you find any difficulty in understanding the above programs.
We can use two loops for much easier executions….
#include
main ()
{
Int n,i,j,k;
printf(“Enter the num/n”);
scanf(“%d”,&n);
for(i=0;i<=n,i++)
for(j=-n;j<=n,j++)
{
k=j;
if(k=i)
printf(“%c”,ch-k);
else
printf(” “);
}
printf(“/n”);
}
1. 1
12. 21
123. 321
1234 4321
123454321
#include
#include
int main()
{
int i,j,k;
int space;
int limit=71;
for(i=0;i<=6;i++)
{
for(k=65;k<=limit;k++)
printf("%c",k);
space=i*2-1;
for(j=1;j=65;k–)
{
if(k<=70)
printf("%c",k);
}
printf("\n");
limit–;
}
return 0;
}
what if i want the output as
A
BA
CBA
DCBA
EDCBA what to do then? (code in c++ please)
#include
using namespace std;
int main()
{
char alpha;
for(char ref=’A’; ref=’A’; alpha–)
{
cout<<alpha;
}
cout<<endl;
}
return 0;
}
write a code for following out put
ACB
CED
EGF
GIH
IKJ
what if I want the output as:-
A B C D E F G
A B C E F G
A B F G
A G
If i want following pattern what is the code
AAAAA
BBBB
CC
D
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
System.out.println(“Hello World”);
char arr[] = new char[27];
Scanner sc = new Scanner(System.in);
char Char = sc.next().charAt(0);
// int no = sc.nextInt();
int z = (int)Char;
int f = z;
int l = 2*(z-65);
System.out.println(z+” “);
for(int k =0 ;k<=(z-65);k++){
for(int i=65;i<= f;i++)
{
if(i0){
for(int m =(2*k);m>0; m–){
System.out.print(” “);
} }
}
if(i>=f){
if(k==0){for(int j=(f-k-1);j>64;j–){
char y = (char)(j);
System.out.print(y+” “);
}}
else{
if(k>=2){
for(int m = 2*(k-1);m>0; m–)
{
System.out.print(” “);
}
}
for(int j=(f-k);j>64;j–){
char y = (char)(j);
System.out.print(y+” “);
}
}
}
}
System.out.println(” “);
}
}
}
/* output
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA */
#include
#include
void main()
{
int I,j,k,m,ch=65;
clrscr();
for(i=1;i>=5;i++)
{
for(j=5;j>=i;j–)
{
Printf(“”);
}
for(k=1;k<=i;k++)
{
Printf("℅c",ch++);
}
ch–;
for(m=1;m<i;m++)
{
Printf("℅c",–ch);
}
Printf("\n");
}
getch();
}
What will the C coding for the following pattern:
A B C D E F G
A B C E F G
A B F G
A G
7654321234567
765432 234567
76543. 34567
7654. 4567
765. 567
76. 67
7. 7
Want you help me with this c++ project
A+b/c-d
A+b/a2
B2-4a2/2a