Print Patterns in C : part 5


Levels of difficulty: / perform operation:

Patterns Part 1
Patterns Part 2
Patterns Part 3
Patterns Part 4
Patterns Part 5


Output : 41

E
DE
CDE
BCDE
ABCDE

Program : 41

#include <stdio.h>
int main() {
	int i, j;
	for (i=5;i>=1;i--) {
		for (j=i;j<=5;j++) {
			printf("%c",'A' + j-1);
		}
		printf("\n");
	}
	return 0;
}





Output : 42

ABCDE
BCDE
CDE
DE
E

Program : 42

#include <stdio.h>
int main() {
	int i, j;
	for (i=1;i<=5;i++) {
		for (j=i;j<=5;j++) {
			printf("%c", 'A'-1 + j);
		}
		printf("\n");
	}
	return 0;
}





Output : 43

EDCBA
EDCB
EDC
ED
E

Program : 43

#include <stdio.h>
int main() {
	int i, j;
	for (i=1;i<=5;i++) {
		for (j=5;j>=i;j--) {
			printf("%c",'A'-1 + j);
		}
		printf("\n");
	}
	return 0;
}





Output : 44

EDCBA
DCBA
CBA
BA
A

Program : 44

#include <stdio.h>
int main() {
	int i, j;
	for (i=5;i>=1;i--) {
		for (j=i;j>=1;j--) {
			printf("%c",'A'-1 + j);
		}
		printf("\n");
	}
	return 0;
}





Output : 45

EEEEE
DDDD
CCC
BB
A

Program : 45

#include <stdio.h>
int main() {
	int i, j;
	for (i=5;i>=1;i--) {
		for (j=1;j<=i;j++) {
			printf("%c",'A'-1 + i);
		}
		printf("\n");
	}
	return 0;
}





Output : 46

AAAAA
BBBB
CCC
DD
E

Program : 46

#include <stdio.h>
int main() {
	int i, j;
	for (i=1;i<=5;i++) {
		for (j=5;j>=i;j--) {
			printf("%c",'A'-1 + i);
		}
		printf("\n");
	}
	return 0;
}





Output : 47

A
AB
ABC
ABCD
ABCDE

Program : 47

#include <stdio.h>
int main() {
	int i, j;
	for (i=1;i<=5;i++) {
		for (j=1;j<=i;j++) {
			printf("%c",'A' + j-1);
		}
		printf("\n");
	}
	return 0;
}





Output : 48

E
DE
CDE
BCDE
ABCDE

Program : 48

#include <stdio.h>
int main() {
	int i, j;
	for (i=5;i>=1;i--) {
		for (j=i;j<=5;j++) {
			printf("%c",'A' + j-1);
		}
		printf("\n");
	}
	return 0;
}





Output : 49

1 
1 2 
3 5 8 
13 21 34 55 
89 144 233 377 610 

Program : 49

#include<stdio.h>

int fib(int);
int main() {
	int i,j,k=1;
	for (i=1;i<=5;i++) {
		for (j=1;j<=i;j++) {
			printf("%d ",fib(k++));
		}
		printf("\n");
	}
	return 0;
}
int fib(int n) {
	if(n<=1)
	    return n;
	return(fib(n-1)+fib(n-2));
}





Output : 50

11111
10001
10001
10001
11111

Program : 50

#include<stdio.h>

int main() {
	int i,j;
	for (i=1;i<=5;i++) {
		for (j=1;j<=5;j++) {
			if(j==5 || j==1 || i==1 || i==5)
			                printf("1"); else
			                printf("0");
		}
		printf("\n");
	}
	return 0;
}





Quantitative Aptitude
Reasoning
Programming
Interview