Posts

Showing posts from February, 2015

Change the output's text colour in C

Hi friends, today I am going to share a funny code with you, which will change the colour of the text of out of your C console proram.  here's the code is. : #include<stdio.h> #include<conio.h> int main() {    clrscr();    textcolor(8);    cprintf("Hello world");    getch();    return 0; } You can change the value of  "textcolor(n);" function.  here "n" may be any interger value. Try it and have fun..

Sum up to given number.

A program for find the sum upto the number entered by the user: #include<stdio.h> #include<conio.h> void main() { clrscr(); int y,t,sum=0; printf("Enter the last value of the series, up to where the sum is required:  "); scanf("%d",&t); for(y=1;y<=t;y++) {  sum=sum+y; } printf("Sum of the series is: %f",sum); getch(); getch(); }

Program to find "Factorial value".

Program code for factorial without recursion : #include<stdio.h> #include<conio.h> void main()     { int i,f=1,n; clrscr(); printf("\nEnter a value: \n"); scanf("%d",&n); for(i=1;i<=n;i++)   { f=f*i;   } printf("Factorial value = %d",f); getch();     }

Pattern Printing

Image
Hi friends.. After a long time i am here back with program codes now. today i am going to write a program for pattern printing. I am writing code to print the following pattern: Code to print this pattern is:  #include<stdio.h> #include<conio.h> void main() { int i,j,k; clrscr(); i=1; while(i<=13) { if(i<=4) { k=3;    while(k>=i)     {       printf(" ");       k--;     }      j=1;      while(j<=i)      {       printf("* ");       j++;      }  }  if(i>4 && i<=7)  {   k=5;   while(k<=i)   {   printf(" ");   k++;   }   j=7;   while(j>=i)   {   printf("* ");   j--;   }   }   if(i>7 && i<=10)   {    k=9;    while(k>=i)    {    printf(" ");    k--;    }    j=7;    while(j<=i)    {    printf("* ");    j++;    }    }    if(i>10)    {    k=