C Programming

C Programming


Reverse L-Shape Pyramid

Posted: 27 Aug 2013 01:55 AM PDT

Q. Write a C program to print the following Reverse L-Shape pyramid as:

*************
*
*
*
*
*
*
*


Ans.

/*c program for reverse L-shape pyramid*/
#include<stdio.h>
int main()
{
 int c;

 for(c=1; c<=13; c++)
    printf("*");
 for(c=1; c<=7; c++)
    printf("*\n");
 getch();
 return 0;
}

/**************************************************************
The output of above program would be:
**************************************************************/


Output of reverse L-Shape Pyramid C program
Figure : Screen shot for reverse L-Shape pyramid C program



C Star Triangle

Posted: 27 Aug 2013 01:22 AM PDT

Q. Write a C program to make the following star triangle as:

*
**
**
**
******

Ans.

/*c program for star triangle design*/
#include<stdio.h>
int main()
{
 int r,c,n;
 printf("*\n");

 for(r=1; r<=4; r++)
 {
  if(r<=3)
  {
    for(c=1; c<=2; c++)
        printf("*");
  }
  else
  {
    for(c=1; c<=6; c++)
        printf("*");
  }
  printf("\n");
 }
 getch();
 return 0;
}

/*************************************************************
The output of above program would be:
**************************************************************/


Output of star triangle pyramid C program
Figure : Screen shot for star triangle C program



Post a Comment

ComputerGeek

ComputerGeek


Most useful jQuery functions

Posted: 26 Aug 2013 11:25 PM PDT

Most useful jQuery functions In this article, I have provided list of most commonly used jQuery functions. List of jQuery functions: 1. jQuery Selectors: //--- COMMON JQUERY SELECTORS ---// // get element by id $("#ElementID").whatever(); // get element by css class $(".ClassName").whatever(); // get elements where id contains a string $("[id*='value']").whatever(); // get


Post a Comment

IPL Twenty20 Cricket

IPL Twenty20 Cricket


SLC Board confirmed Lasith Malinga unlikely to miss CLT20

Posted: 26 Aug 2013 05:07 AM PDT

The Sri Lanka fast bowler and one of the most risk T20 bowlers in the world, Lasith Malinga has sent out a leave call for to both Sri Lanka cricket (SLC) and the Mumbai Indians ask for his absence from the T20 Cricket League and Sri Lanka's tour to Zimbabwe due to individual reasons and Malinga has requested the time off to be with his wife, as the couple be expecting their second child late in September.

For the 2013 Champions League Twenty20 is schedule to start on the 17th of September with Mumbai Indians playing their opening game 4 days later and the Mumbai Indians play for the first Champions League match on September 21, and the tournament finishes on October 6 and the Sri Lanka's tour to Zimbabwe starts at the end of October.


Post a Comment

C Programming

C Programming


Nested Star-Hash Pyramid

Posted: 26 Aug 2013 12:51 AM PDT

Q. Write a C program to print the following star-hash pyramid design:

#####*#####
####*#*####
###*###*###
##*#####*##
#*#######*#
*#########*

/**************************************************************
How To Make Above nested Pyramid C program
***************************************************************
So you can see, there are four types pyramid in above design as:

 #####      *         #####
 ####      *#   *      ####
 ###      *##   #*      ###
 ##      *###   ##*      ##
 #      *####   ###*      #
       *#####   ####* 

Hence, now it is easy to make these above pyramid program. So i recommended to make first above four pyramid program, after making these pyramid design, add these all pyramid in single C program and you are done. :) )
**************************************************************/

Ans.

/*c program for nested star-hash pyramid*/
#include<stdio.h>
int main()
{

 int n=5,r,c;
 for(r=1; r<=6; r++,n--)
 {
   /*first pyramid*/
   for(c=1; c<=n; c++)
     printf(" #");
   /*second pyramid*/
   for(c=1; c<=r; c++)
   {
     if(c==1)
        printf(" *");
     else
        printf(" #");
   }
   /*third pyramid*/
   for(c=r; c>1; c--)
   {
     if(c==2)
        printf(" *");
     else
        printf(" #");
   }
   /*fourth pyramid*/
   for(c=n; c>=1; c--)
        printf(" #");
   printf("\n");
 }
 getch();
 return 0;
}

/*************************************************************
The output of above program would be:
**************************************************************/


Output of nested hash-star pyramid C program
Figure : Screen shot for nested Hash-Star
Pyramid C program



Post a Comment

C Programming

C Programming


Binary Geometric Number Pyramid

Posted: 25 Aug 2013 02:49 AM PDT

Q. Write a C program to print the following binary geometric number pyramid as:

 1
 2 3
 4 5 6 7
 8 9 10 11 12 13 14 15
 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

or

 7
 14 15
 28 29 30 31
 56 57 58 59 60 61 62 63

[How to create : in above pyramid design, left hand side vertical left align elements are as 1, 2, 3, 4, 8 as geometric sequence numbers. And each these number increase to +1, till equal the binary number as 1, 2, 4, 8, 16 and so on.
]

Ans.

/*c program for generating geometric sequence of any number*/
#include<stdio.h>
int main()
{
 int num,n,r,c,rows,x=1;

 printf("Enter any number : ");
 scanf("%d", &num);
 printf("Enter total rows : ");
 scanf("%d", &rows);
 for(r=1; r<=rows; r++,x=x*2)
 {
   n=x*num;
   for(c=1; c<=x; c++)
       printf(" %d",n++);
   printf("\n");
 }
 getch();
 return 0;
}

The output of above program would be:

Output of binary geometric sequence pyramid C program
Figure : Screen shot for binary geometric sequence
 pyramid C program


Output of binary geometric sequence pyramid C program
Figure : Screen shot for binary geometric sequence
 pyramid C program




Post a Comment

C Programming

C Programming


Number Triangle Design

Posted: 23 Aug 2013 06:17 AM PDT

Q. Write a C program to print the following number triangle or pyramid design as:

1
121
12321
1234321

Ans.

/*c program for number triangle design*/
#include<stdio.h>
int main()
{
 int num,r,c,z;
 printf("Enter any number : ");
 scanf("%d", &num);

 for(r=1; r<=num; r++)
 {
  for(c=1; c<=r; c++)
     printf("%d",c);
  for(z=r-1; z>=1; z--)
     printf("%d",z);
  printf("\n");
 }
 getch();
 return 0;
}

The output of above program would be:

Output of Number Triangle C program
Figure : Screen shot for Number Triangle C program

Alternate Number-Star Pyramid

Posted: 23 Aug 2013 05:24 AM PDT

Q. Write a C program to print the following alternate number-star pyramid/triangle as:

1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1

Ans.

/*c program for alternate number-star pyramid*/
#include<stdio.h>
int main()
{
 int num,r,c,z=1,p,n;
 printf("Enter maximum number : ");
 scanf("%d", &num);

 for(r=1; r<=num; r++,z=z+2)
 {
  for(c=1; c<=z; c++)
  {
    if(c%2==0)
       printf("*");
    else
       printf("%d",r);
  }
  printf("\n");
 }
 n=num+3;
/*
NOTE: increase +1 above digit when you increase maximum number to 4 
For example: if you enter:
num=5 then n=num+4
if num=6 then n=num+5 and so on. 
*/
 p=num;
 for(r=num; r>=1; r--,n=n-2,p--)
 {
  for(c=1; c<=n; c++)
  {
    if(c%2==0)
       printf("*");
    else
       printf("%d",p);
  }
  printf("\n");
 }
 getch();
 return 0;
}

The output of above program would be:


Output of Alternate Number-Star Pyramid C program
Figure : Screen shot for Alternate Number-Star
 Triangle C program

Number Triangle Design

Posted: 23 Aug 2013 04:06 AM PDT

Q. Write a C program to design the number triangle pyramid as:

1
121
1231
12341
123451

Ans.

/*c program for number triangle design*/
#include<stdio.h>
int main()
{
 int num,r,c,z;
 printf("Enter No. of rows : ");
 scanf("%d", &num);

 for(r=1; r<=num; r++)
 {
  for(c=1; c<=r; c++)
     printf("%d",c);
  for(z=1; z<r; z++)
  {
     printf("%d",z);
     break;
  }
  printf("\n");
 }
 getch();
 return 0;
}

The output of above program  would be:

Output of Number Triangle Design C program
Figure: Screen shot for Number Triangle Design C program

Diagonal Star and Zero Rectangle

Posted: 23 Aug 2013 12:21 AM PDT

Q. Write a C program to print the following diagonal star and zero rectangle structure as:

*000000
0*00000
00*0000
000*000
0000*00
00000*0
000000*

Ans.

/*c program for diagonal star and zero rectangle*/
#include<stdio.h>
int main()
{
 int rows=7,r,c;

 for(r=1; r<=rows; r++)
 {
  for(c=1; c<=rows; c++)
  {
    if( (c==1 && r==1) ||
        (c==2 && r==2) ||
        (c==3 && r==3) ||
        (c==4 && r==4) ||
        (c==5 && r==5) ||
        (c==6 && r==6) ||
        (c==7 && r==7)        
      )
         printf("*");
     else
         printf("0");
  }
  printf("\n");
 }
 getch();
 return 0;
}

The output of above program would be:


Output of Diagonal Star and Zero Rectangle C program
Figure: Screen shot for diagonal star and zero
 rectangle C program


Vertical Continues Number Pyramid

Posted: 23 Aug 2013 12:01 AM PDT

Q. Write a C program to print the following vertical continues number pyramid as:

 1

 23
 4
 56
 7
 89
 10

Ans.

/*c program for vertical continues number pyramid*/
#include<stdio.h>
int main()
{
 int r,c,x,y;

 static int i=1;
 for(r=1; r<=7; r++)
 {
   if(r%2==0)
   {
     for(x=2; x>=1; x--,i++)
        printf("%d",i);
   }
   else
   {
     for(y=1; y>=1; y--,i++)
        printf("%d",i);
   }
   printf("\n");
 }
 getch();
 return 0;
}

The output of above program would be:


Output of Vertical Continues Number Pyramid C program
Figure: Screen shot for vertical continues number
 pyramid C program



Post a Comment

IPL Twenty20 Cricket

IPL Twenty20 Cricket


2013 Champions League Twenty20 Schedule

Posted: 20 Aug 2013 04:05 AM PDT


DateMatch DetailsTime (IST)Place
Sep 21 - SatRR v MI, 1st Match20:00Jaipur
Sep 22 - SunBrisband Heat v T&T, 2nd Match16:00Ranchi
Sep 22 - SunCSK v Titans, 3rd Match20:00Ranchi
Sep 23 - MonLions v Perth Scorchers, 4th Match16:00Ahmedabad
Sep 23 - MonMI v TBC, 5th Match20:00Ahmedabad
Sep 24 - TueBrisbane Heat v Titans, 6th Match16:00Hyderabad
Sep 24 - TueT&T v TBC, 7th Match20:00Hyderabad
Sep 25 - WedPerth Scorchers v TBC, 8th Match16:00Jaipur
Sep 25 - WedLions v RR, 9th Match20:00Jaipur
Sep 26 - ThuCSK v TBC, 10th Match20:00Ranchi
Sep 27 - FriLions v MI, 11th Match20:00Ahmedabad
Sep 28 - SatTitans v TBC, 12th Match16:00Hyderabad
Sep 28 - SatBrisbane Heat v CSK, 13th Match20:00Hyderabad
Sep 29 - SunLions v TBC, 14th Match16:00Jaipur
Sep 29 - SunRR v Perth Scorchers, 15th Match20:00Jaipur
Sep 30 - MonTitans v T&T, 16th Match16:00Hyderabad
Sep 30 - MonCape Brisbane Heat v TBC, 17th Match20:00Hyderabad
Oct 01 - TueRR v TBC, 18th Match20:00Jaipur
Oct 02 - WedMI v Perth Scorchers, 19th Match16:00Delhi
Oct 02 - WedCSK v T&T, 20th Match20:00Delhi
Oct 04 - FriTBC v TBC, 1st Semi-final20:00Jaipur
Oct 05 - SatTBC v TBC, 2nd Semi-final20:00Delhi
Oct 06 - SunTBC v TBC, Final20:00Delhi

CSK - Chennai Super Kings
RR - Rajasthan Royals
MI - Mumbai Indians

T&T - Trinidad and Tobago

2013 Champions League Twenty20 Qualifiers Schedule

Posted: 20 Aug 2013 03:38 AM PDT

DateMatch DetailsTime (IST)Place
Sep 17 - TueFaisalabad Wolves v Otago16:00Hyderabad
Sep 17 - TueKandurata Maroons v Sunrisers20:00Hyderabad
Sep 18 - WedKandurata Maroons v Otago16:00Hyderabad
Sep 18 - WedFaisalabad Wolves v Sunrisers20:00Hyderabad
Sep 20 - FriFaisalabad Wolves v Kandurata Maroons16:00Hyderabad
Sep 20 - FriOtago v Sunrisers20:00Hyderabad


Post a Comment