Saturday, January 4, 2014

C Program for print I Love You

C Program for print I Love You 

Output



Code

#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
int m,i,j=10,k=3;
clrscr();
for(i=0;i<=13;i++)
  {
  gotoxy(j,k);
    textcolor(WHITE+BLINK);
    textbackground(5);
    cprintf("IIII");
  delay(50);
  j++;
  }
  for(i=0;i<=6;i++)
  {
  gotoxy(j,k);
    cprintf("IIII");
  textcolor(WHITE+BLINK);
  textbackground(5);
  delay(50);
  j--;
  }
  for(i=0;i<=6;i++)
  {
  gotoxy(j,k);
    cprintf("IIII");
  textcolor(WHITE+BLINK);
 textbackground(5);
  delay(50);
  k++;
  }
  for(i=0;i<=6;i++)
  {
  gotoxy(j,k);
    cprintf("IIII");
  textcolor(WHITE+BLINK);
 textbackground(5);
  delay(50);
  j--;
  }
  for(i=0;i<=13;i++)
  {
  gotoxy(j,k);
    cprintf("IIII");
  textcolor(WHITE+BLINK);
 textbackground(5);
  delay(50);
  j++;
  }
  j=32,k=7;
  for(i=0;i<=4;i++)
  {
  gotoxy(j,k);
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  cprintf("LLL");
  delay(50);
  j++;
  }
      for(i=0;i<=2;i++)
  {
  gotoxy(j,k);
    cprintf("LLL");
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  j++;
  k++;
  }
    for(i=0;i<=2;i++)
  {
  gotoxy(j,k);
    cprintf("LLL");
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  j++;
  k--;
  }
    for(i=0;i<=4;i++)
  {
  gotoxy(j,k);
    cprintf("LLL");
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  j++;
  }
    for(i=0;i<=2;i++)
  {
  gotoxy(j,k);
    cprintf("LLL");
     textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  j++;
  k++;
  }
    for(i=0;i<=0;i++)
  {
  gotoxy(j,k);
    cprintf("LLL");
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  k++;
  }
    for(i=0;i<=7;i++)
  {
  gotoxy(j,k);
    cprintf("LLL");
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  j--;
  k++;
  }
    for(i=0;i<=5;i++)
  {
  gotoxy(j,k);
    cprintf("LLL");
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  j--;
  }
    for(i=0;i<=7;i++)
  {
  gotoxy(j,k);
    cprintf("LLL");
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  j--;
  k--;
  }
    for(i=0;i<=0;i++)
  {
  gotoxy(j,k);
    cprintf("LLL");
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  k--;
  }
    for(i=0;i<=3;i++)
  {
  gotoxy(j,k);
    cprintf("LLL");
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  j++;
  k--;
  }
  j=50,k=5;
    for(i=0;i<=17;i++)
  {
  gotoxy(j,k);
    cprintf("LLLL");
  textcolor(WHITE+YELLOW+BLINK);
  textbackground(0);
  delay(50);
  j--;
  k++;
  }
  j=55,k=15;
    for(i=0;i<=4;i++)
  {
  gotoxy(j,k);
   textcolor(YELLOW+BLINK);
   textbackground(0);
   cprintf("UUU");
  delay(50);
  k++;
  }
    for(i=0;i<=2;i++)
  {
  gotoxy(j,k);
    cprintf("UUU");
     textcolor(YELLOW+BLINK);
 textbackground(0);
  delay(50);
  j++;
  k++;
  }
    for(i=0;i<=6;i++)
  {
  gotoxy(j,k);
    cprintf("UUU");
     textcolor(YELLOW+BLINK);
 textbackground(0);
  delay(50);
  j++;
  }
    for(i=0;i<=2;i++)
  {
  gotoxy(j,k);
    cprintf("UUU");
     textcolor(YELLOW+BLINK);
 textbackground(0);
  delay(50);
  j++;
  k--;
  }
    for(i=0;i<=5;i++)
  {
  gotoxy(j,k);
    cprintf("UUU");
     textcolor(YELLOW+BLINK);
  textbackground(0);
  delay(50);
  k--;
  }
  j=1,k=1;
    for(i=0;i<=78;i++)
  {
  gotoxy(j,k);
    cprintf(" ");
  textcolor(3);
  textbackground(0);
  delay(50);
  j++;
  }



    for(i=0;i<=45/2;i++)
  {
  gotoxy(j,k);
  cprintf(" ");
  textcolor(3);
  textbackground(0);
  delay(20);
  k++;
  }
    for(i=0;i<=77;i++)
  {
  gotoxy(j,k);
    cprintf(" ");
  textcolor(3);
textbackground(0);
  delay(20);
  j--;
  }
    for(i=0;i<=23;i++)
  {
  gotoxy(j,k);
    cprintf(" ");
  textcolor(3);
  textbackground(0);
  delay(20);
  k--;
  }
  j=9;k=13;
for(m=10;m<15;m++)
{
 j++;
 textcolor(m);
   for(i=0;i<4;i++)
  {
  gotoxy(j,k);
    cprintf("ILU");
 k++;  delay(20);
  j--;
  k++;
  }
     for(i=0;i<4;i++)
  {
  gotoxy(j,k);
    cprintf("ILU");
  delay(20);
  j++;
  k++;
  }
      for(i=0;i<4;i++)
  {
  gotoxy(j,k);
    cprintf("ILU");
  delay(20);
  j++;
  k--;
  }
    for(i=0;i<4;i++)
  {
  gotoxy(j,k);
    cprintf("ILU");
  delay(20);
  j--;
  k--;
  }
  }
   j=60;k=3;
for(m=10;m<15;m++)
{
 textcolor(m);
 j++;
   for(i=0;i<4;i++)
  {
  gotoxy(j,k);
    cprintf("ILU");
  delay(20);
  j--;
  k++;
  }
     for(i=0;i<4;i++)
  {
  gotoxy(j,k);
    cprintf("ILU");
  delay(20);
  j++;
  k++;
  }
      for(i=0;i<4;i++)
  {
  gotoxy(j,k);
    cprintf("ILU");
  delay(20);
  j++;
  k--;
  }
    for(i=0;i<4;i++)
  {
  gotoxy(j,k);
    cprintf("ILU");
  delay(20);
  j--;
  k--;
}
  }
  j=20;k=25;
  gotoxy(j,k);
    textcolor(WHITE);
    textbackground(0);
  cprintf("for more program visit Now : gauravsiwach.blogspot.in");
  getch();
  }




Friday, January 3, 2014

C Program for find a matrix is Magic Square


C Program for find a matrix is magic square.

/*this program input the a  square matrix and after checked  that print the message entered matrix is magic    
   square or not*/


#include<stdio.h>
#include<conio.h>
void main()
{
 int matrix[10][10],n,i,j,r_sum,c_sum,rd_sum,ld_sum;
 int sum[10],f=0;
  r_sum=c_sum=rd_sum=ld_sum=0;

 clrscr();
                 printf("Enter the Size of Square Matrix :");
                 scanf("%d",&n);

                printf("Enter the Matrix :");
                 for(i=0;i<n;i++)
                  for(j=0;j<n;j++)
                                scanf("%d",&matrix[i][j]);

                 printf("Enterd Matrix is :\n");
                  for(i=0;i<n;i++)
                  {
                  for(j=0;j<n;j++)
                                printf("%d\t",matrix[i][j]);
                                  printf("\n");
                  }

                  for(i=0;i<n;i++)
                                   sum[i]=0;

                 for(i=0;i<n;i++)
                 { r_sum=0;
                   c_sum=0;
                                  for(j=0;j<n;j++)
                                  {
                                   r_sum=r_sum+matrix[i][j];
                                   c_sum=c_sum+matrix[j][i];

                                   if(i==j)
                                                   ld_sum=ld_sum+matrix[i][j];

                                   if((i+j)==n-1)
                                                   rd_sum=rd_sum+matrix[i][j];

                 }
                  sum[i]=r_sum;
                  sum[i+n]=c_sum;
                 }
                 sum[n+i]=rd_sum;
                 sum[n+i+1]=ld_sum;

                 r_sum=sum[0];

                   for(i=0;i<(n*2+2);i++)
                                if(r_sum!=sum[i])
                                                 {
                                                                 f=1;
                                                                 break;
                                                 }

                   if(f==0)
                                    printf("\n\tits a Magice Square.");
                   else
                                    printf("\n\tits not a Magice Square.");

                 getch();
 }


Output:

Enter the Size of Square Matrix :  3
2     7       6
9     5       1
4     3       8

           It’s a Magic Square.


C Program for find difference between two date

C Program for find difference between two date

Code

#include<stdio.h>
#include<conio.h>
void main()
{
     int date1,date2,month1,month2,year1,year2,leap_day,i;
     long int year_differnt,totalday1=0,totalday2=0,total_day;
     int day[]={31,0,31,30,31,30,31,31,30,31,30,31};
   
     printf("enter the 1st date month and year");
     scanf("%d%d%d",&date1,&month1,&year1);
   
     printf("enter the 2nd date month and year");
     scanf("%d%d%d",&date2,&month2,&year2);
   
     for(i=month1;i<12;i++)
     {
                          if(i==2)
                          {
                                  if((year1%4==0)||((year1%100==0)&(year1%400)))
                                      totalday1=totalday1+29;
                                  else
                                       totalday1=totalday1+28;
                          }
                          else      
                                      totalday1=totalday1+day[i];
     }                  
   
     totalday1=totalday1+date1;
   
     for(i=month2;i<12;i++)
     {
                          if(i==2)
                          {
                                  if((year1%4==0)||((year1%100==0)&(year1%400)))
                                      totalday2=totalday2+29;
                                  else
                                       totalday2=totalday2+28;
                          }
                          else      
                                      totalday2=totalday2+day[i];
     }                  
   
     totalday2=totalday2+date2;  
     if(year1<=year2)
      year_differnt=year2-year1;
     else
         year_differnt=year1-year2;
 
     leap_day= year_differnt/4;
   
     total_day= (year_differnt*365)+leap_day;
 
     if(totalday1>totalday2)
   
                total_day= total_day+(totalday1-totalday2);
     else
                total_day= total_day+(totalday2-totalday1);

     printf("\n%d-%d-%d",date1,month1,year1);
     printf("\n%d-%d-%d",date2,month2,year2);
   
     printf("\n difference  between following date is :%ld day",total_day);

     getch();

 }

Output




how to delete a file using c program

how to delete a file using c program

This c program deletes a file which is entered by the user, the file to be deleted should be present in the directory in which the executable file of this program is present. Extension of the file should also be entered, also note that deleted file doesn't go to recycle bin, remove macro is used to delete the file. 

Code

#include<stdio.h>
#include<conio.h>
void main()
{
   int status;
   char file_name[25];
   printf("Enter the name of file you wish to delete\n");
   gets(file_name);
   status = remove(file_name);

   if( status == 0 )
      printf("%s file deleted successfully.\n",file_name);
   else
      printf("Unable to delete the file\n");
  
   getch();
   
}

Wednesday, December 18, 2013

How to open thumbnail image in large view on facebook.


How to open thumbnail image in large view on facebook.
Please do-not Misuse it.

Step -1. Open any Facebook profile.
Step -2. Right click on the profile picture and click “Copy image URL”.
                                    Or

  Right click on the profile picture and click “Open image in new tab”.



Paste the copied URL in a notepad or address bar. you will see something look like this
fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/c120.0.720.720/s160x160/941834_691157654228570_1826110726_n.jpg

If you observe the above URL, you Will notice that the text in green color matches the thumbnail size of the profile picture.

Step #3. Now you have need to replace s160×160 with s720×720 in the above link , so your new link will look something like this

fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/c120.0.720.720/ s720×720 /941834_691157654228570_1826110726_n.jpg

Step #4. Now just visit this new url.
you have the original profile picture on your Screen.

Sunday, December 15, 2013

Programming Challenges Question 1

Programming Challenges Question 

Write a program which will print the below structures according to the input provided to the program.
The program should accept 3 inputs in the form of numbers between 1 and 9, both inclusive (one number per line) and then generate the corresponding structures based on the input.
Suppose the following sequence of numbers is supplied to the program:
3
2
4

Then the output should be:
  1
 2 2
3 3 3
 1
2 2
   1
  2 2
 3 3 3
4 4 4 4

/**********************Code1 in JAVA******************************/
import java.io.*;
public class Main {
public static void main(String[] args) {
    try
    {
        int a[]= new int[3];
    InputStreamReader sr= new InputStreamReader(System.in);
    BufferedReader br= new BufferedReader(sr) ;
     System.out.print("Enter 3 Number:\n");
     for(int i=0;i<3;i++)
     {
      a[i] = Integer.parseInt(br.readLine());
     }
     for(int count=0;count<3;count++)
     {
        for(int i=1;i<=a[count];i++)
          {
             for(int j=a[count];j>i;j--)
             {
                 System.out.print(" ");
             }
             for(int k=1;k<=i;k++)
             {
              System.out.print(k+" ");
             }
             System.out.println();
          }
     }
    }
    catch(Exception ex)
    {
        System.out.println(ex);
    }
    }

    }


/******************************** Code2 in JAVA*********************************/
 import java.util.Scanner;
public class Main
{
    public static void main(String args[])
    {
   int a,b,c;
 Scanner in = new Scanner(System.in);
 a = in.nextInt();
 b = in.nextInt();
 c = in.nextInt();
 int[] array={a,b,c};
    int k;
  for(int x=0; x<3; x++){
  int y = array[x];
  int z= y+1;
   for(int i=1;i<=y;i++){
   System.out.println();
   System.out.format("%"+z+"s", "");

    for(int j=1;j<=i;j++)
    {
    k=i;
    System.out.format("%"+1+"s", "");
    System.out.print(k);
    }
    z--;
   }
  }
   }
}



Programming Challenges Question 2

Programming Challenges Question 
Write a program which will accept a single pair of strings separated by a comma; the program should calculate the sum of ascii values of the characters of each string. The program should then subtract the sum of the ascii values of the second string from the sum of the ascii values of the first string.

Suppose the following input is given to the program: 

123ABC,456DEF

Then the sum of the ascii values of the characters in '123ABC' is 348 and in '456DEF' it is 366. The Difference between these numbers is 348 – 366 = -18
The corresponding output to be printed by the program is: 
-18

/*****************************Code in JAVA********************************/
import java.io.*;
public class Main {
public static void main(String[] args) {
 
    try
    {

    InputStreamReader sr= new InputStreamReader(System.in);
    BufferedReader br= new BufferedReader(sr) ;
    String str=br.readLine();
    String data[]= str.split(",");
    int sum[]= new int[data.length];
    for(int i=0;i<data.length;i++)
    {
        for(int j=0;j<data[i].length();j++)
        {
           sum[i]=sum[i]+ (int) data[i].charAt(j);
        }
     
    }
    int dif=sum[0];
    for(int i=1;i<sum.length;i++)
        {
             dif=dif-sum[i];
         }
    System.out.println("Diff :"+dif);
    }
    catch(Exception ex)
    {
        System.out.println(ex);
    }
  }
}