Showing posts with label print. Show all posts
Showing posts with label print. Show all posts
Sunday, February 15, 2015
C C Program to Print Following Pattern
ABCDEFGFEDCBA
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A

Comment below if you find any difficulty in understanding the above programs.
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A
C Program
#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("
");
}
return 0;
}
C++ Program
#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<<"
";
}
return 0;
}

Comment below if you find any difficulty in understanding the above programs.
Saturday, February 14, 2015
C program to print numbers from 1 to 10 using for loop
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr(); //to clear the screen
for(i=1;i<=10;++i)
{
printf("%d",i);
printf("
");
}
getch(); //to stop the screen
}
Subscribe to:
Posts (Atom)