#include <stdio.h>
int main() {
char prnt = 'A';
int i, j;
for (i = 1; i <= 5; i++) { // Prints the right angle triangle
for (j = 1; j <= i; j++) {
printf("%2c", ((prnt + (i - j)))); // Prints the characters in the required order
}
printf("\n");
}
return 0;
}
Sunday, 17 March 2013
Write a C program to print the following pattern: A B A C B A D C B A E D C B A
Write a C program to print the following pattern: A B A C B A D C B A E D C B A
#include <stdio.h>
int main() {
char prnt = 'A';
int i, j;
for (i = 1; i <= 5; i++) { // Prints the right angle triangle
for (j = 1; j <= i; j++) {
printf("%2c", ((prnt + (i - j)))); // Prints the characters in the required order
}
printf("\n");
}
return 0;
}
Write a C program to print the following pattern: A B A C B A D C B A E D C B A
#include <stdio.h>
int main() {
char prnt = 'A';
int i, j;
for (i = 1; i <= 5; i++) { // Prints the right angle triangle
for (j = 1; j <= i; j++) {
printf("%2c", ((prnt + (i - j)))); // Prints the characters in the required order
}
printf("\n");
}
return 0;
}
Write a C program to print the following pattern: A B A C B A D C B A E D C B A
#include <stdio.h>
int main() {
char prnt = 'A';
int i, j;
for (i = 1; i <= 5; i++) { // Prints the right angle triangle
for (j = 1; j <= i; j++) {
printf("%2c", ((prnt + (i - j)))); // Prints the characters in the required order
}
printf("\n");
}
return 0;
}
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int bubblesort(int *,int);
int bubblesort(int *arr,int n)
{
int i,j,temp;
for(i=0;i<n-1;i++)
{
for(j=0;j<(n-1-i);j++)
{
if(*(arr+j)>*(arr+j+1))
{
temp=*(arr+j);
*(arr+j)=*(arr+(j+1));
*(arr+(j+1))=temp;
}
}
return 0;
}
}
int main()
{
int *arr,i,n;
printf("enter the no of terms\n");
scanf("%d",&n);
arr=(int *)malloc(sizeof(n*sizeof(int )));
printf("Enter the elements");
for(i=0;i<n;i++)
scanf("%d",(arr+i));
bubblesort(arr,n);
printf("sorted elements are\n");
for(i=0;i<n;i++)
printf("%d",*(arr+i));
return 0;
}
#include<conio.h>
#include<stdlib.h>
int bubblesort(int *,int);
int bubblesort(int *arr,int n)
{
int i,j,temp;
for(i=0;i<n-1;i++)
{
for(j=0;j<(n-1-i);j++)
{
if(*(arr+j)>*(arr+j+1))
{
temp=*(arr+j);
*(arr+j)=*(arr+(j+1));
*(arr+(j+1))=temp;
}
}
return 0;
}
}
int main()
{
int *arr,i,n;
printf("enter the no of terms\n");
scanf("%d",&n);
arr=(int *)malloc(sizeof(n*sizeof(int )));
printf("Enter the elements");
for(i=0;i<n;i++)
scanf("%d",(arr+i));
bubblesort(arr,n);
printf("sorted elements are\n");
for(i=0;i<n;i++)
printf("%d",*(arr+i));
return 0;
}
Subscribe to:
Comments (Atom)