9.09.2012

Run Command Shortcuts

If you want to work faster at computer system, then it is best practise to use keyboard shortcuts.

If you want to start a new application / utilities, then you navigate hundred windows and dialog boxes. Or rather then you can do same job through "Run Command".

How to reach run command?

  1. Start > Run
  2. press ( [Windows] + [R] )
The keyboard shortcuts for run command in Windows XP:


Mostly use run command shortcuts as:

Calculator -------------------------------  calc
  Character map --------------------------  charmap  
Clipboard --------------------------------  clipbrd
  Command Prompt ----------------------  cmd or command  
Computer Management ---------------  compmgmt.msc
  Control panel --------------------------  control  
Display Properties --------------------  desk.cpl or control desktop
  Date and Time properties ----------  timedate.cpl  
Fonts -----------------------------------  control fonts
  Game Controllers ---------------------  joy.cpl  
Internet Explorer ---------------------  iexplore
  Keyboard Properties -----------------  control keyboard  
Microsoft Word -----------------------  winword
  Microsoft Excel -----------------------  excel  
Microsoft PowerPoint ----------------  powerpnt
  Microsoft Paint -----------------------  mspaint or pbrush  
Mouse Properties --------------------  main.cpl
  Notepad ------------------------------  notepad  
On Screen Keyboard ----------------  osk
  Outlook Express --------------------  msimn  
Printers and Faxes --------------------  control printers
  Regional Settings -------------------  intl.cpl  
shutdown Windows -------------------  shutdown
  Sounds and Audio ---------------------  mmsys.cpl  
System Configuration Editor ---------  sysedit
  System Configuration Utility ---------  msconfig  
System Information -------------------  msinfo32
  System Properties ---------------------  sysdm.cpl  
Task Manager --------------------------  taskmgr
  Windows Explorer ---------------------  explorer  
Windows Firewall ----------------------  firewall.cpl
  Windows Magnifier --------------------  magnify  
Windows Media Player ----------------  wmplayer
  Windows System Security Tool ------  syskey  
Windows Version ----------------------  winver
  Wordpad --------------------------------  write  


Related programs:


  1. Make your own Windows Run command
  2. General keyboard shortcuts
  3. Windows keyboard shortcuts
  4. Dialog box shortcuts
  5. Function key shortcuts

Number Pyramid

Q. Write a C program to print the following number triangle.
or
Q. Write a C program to display the following number pyramid.

       1
      222
     33333
    4444444
   555555555

Ans.

/*c program for number pyramid*/
#include<stdio.h>
#include<conio.h>
int main()
{
 int num,r,c,k,sp;
 printf("Enter number of rows : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++)
 {
  for(sp=num-r; sp>0; sp--)
     printf(" ");
  for(c=1; c<=r; c++)
     printf("%d", r);
  for(k=2; k<=r; k++)
     printf("%d", r);
  printf("\n");
 }
 getch();
 return 0;
}

/**************Output**************/

Output of number pyramid C program
Screen shot for number pyramid C program

9.04.2012

Pointer basic example

We has been discuss about what is pointer and concept of pointer. Now the following program demonstrates the relationship of our pointer discussion.

#include<stdio.h>
int main()
{
   int x = 5;
   int *y;

   y = &x;
   printf("\nAddress of x = %u", &x);
   printf("\nAddress of x = %u", x);
   printf("\nAddress of y = %u", &y);
   printf("\nValue of y = %d", y);
   printf("\nValue of x = %d", x);
   printf("\nValue of x = %d", *(&x));
   printf("\nValue of y = %d", *y);

  getch();
  return 0;
}

The output of above program would be:

Address of x = 2293620
Address of x = 5
Address of y = 2293616
Value of y = 2293620
Value of x = 5
Value of x = 5
Value of y = 5

/* Screen shot for above program */

Output of pointer basic example C program
Screen-shot for pointer basic example C program


note: the address of variable may be differ because its depend on compiler. I use Bloodshed software "Dev-C++" so you can see that here integer occupy 4 bytes.

The above program summarizes everything that we discussed in what is pointer and concept of pointer chapters. If you don't understand the program output, or the meaning of &x, &y, *y and *(&x), re-read the last 2 chapter of pointer:
What is pointer
Concept of pointer

Now look at the following declaration:

int *n;
char *ch;
float *area;

Here, n, ch and area are declared as pointer variable, i.e. these variable capable of holding addresses.
Keep in mind: Address ( location numbers ) are always whole numbers.
In summarize "we can say pointers are variable that contain addresses and addresses are always whole numbers."

The declaration float *area does not mean that area is going to contain a floating-point value. The meaning is, *area is going to contain the address of a floating-point value.
Similarly, char *ch means that ch is going to contain the address of a char value or in other words, the value at address stored in ch is going to be a char.

Now we know that "Pointer is a variable that contains address of another variable."
Can we further extended it? The answer is Yes, we can. Read in next chapter "Pointer Extended Example".


Related programs:


  1. What is pointer ?
  2. Concept of Pointer
  3. Pointer extend example

9.02.2012

Concept of Pointer

In last chapter ( what is pointer ) , we learn what is the basic of pointer. Now we are learning what is the concept of pointer and how to using it.

In last chapter we declare a variable
int n = 10 ;
and create a memory map, Now we learn how to do this.

Now we print the address of variable through following program:

#include<stdio.h>
int main()
{
  int n = 10;
  printf("\nAddress of n =%u", &n);
  printf("\nValue of n =%d", n);
  getch();
  return 0;
}

The output of above program:

Address of n = 65220
Value of n = 10

Useful tips i.e. explanations of above programs:
  • Look at the first printf() statement carefully, it used & ( address of operator ). So & return the address of memory location. In our case, the expression  &n return the address of variable n.
  •  %u is used for printing the unsigned integer.
Now, observe carefully the output of the following program:

#include<stdio.h>
int main()
{
  int n = 10;
  printf("\nAddress of n =%u", &n);
  printf("\nValue of n =%d", n);
  printf("\nValue of n =%d", *(&n));
  getch();
  return 0;
}

The output of above program:


Address of n = 65220
Value of n = 10
Value of n = 10

here you can notice that the value of *(&n) is same as printing the value of n.

The expression &n gives the address of the variable n. This address can be collected in a variable, by saying:

int p = &n;

but here 1 problem, p is simple variable so we can't use of variable p.
What is solution?
So here comes the concept of pointer. Now we declare the integer variable p as integer pointer variable:

int *p;
This declaration tells the compiler that p will be used to store the address of an integer value i.e. p points to an integer.

int *p;

Now let's understand the meaning of *. It stand for value at address  operator. It return the value at stored at particular address.
The "value at address" operator is also known "indirection operator".

Thus, 
int *p; would mean, the value at the address contained in p is an int.

let's check out what you grab:
Q. What will be output of following program?
  
     #include<stdio.h>
     int main()
     {
        int n = 10;
        printf("\nOutput of n =%d", n);
        printf("\nOutput of *n =%d", *n);
       getch();
       return 0;
     }

Ans.

Output of n = 10
Output of *n = error ( invalid indirection)

Can you understand why second printf() statement generate error? if yes then congratulation... And if you can't figure out then also don't worry because our next chapter is pointer practice session, in this you grab all about pointer.

The reason second printf() statement is generating error because, "value at address ( * )" is used only pointer variable/directly address i.e. "value at address" does not work with simple variable.
In our case n is simple variable and so compiler generate error.


Related programs:


  1. What is Pointer ?
  2. Pointer basic example
  3. Pointer extend example

What is Pointer

What is Pointer?

Pointer is a special variable that represent the address/location of the data item. It provides an alternative way to access the value of a variable.
Pointer is used only store/hold memory address of any variable.

There are some reason to why Pointer used in programs:

  1. A pointer able to access a variable that is defined outside the function.
  2. Pointer are more efficient in handle the data table.
  3. Pointers reduce the length and complexity of the program.
  4. Pointer increase the speed of program execution.
  5. The use of the Pointer array to character string, result in saving of data storage space in memory.
Pointer Notation

Let's declare a integer variable n which value is 10:

int n = 10 ;

What is this meaning? The above declaration tells the C compiler that:

  1. Reserve space in memory to hold the integer value i.e. 65220
  2. Associate the name with this memory location i.e. n
  3. Store the value at location i.e. 10 
and the memory map of above declaration as:

       n --------> location name
     10 --------> value at location
65220 --------> location/address number

The important point to note in memory map that n's address in memory is a number ( in next chapter we see how it is important? ).


Related programs:


  1. Concept of Pointer
  2. Pointer basic example
  3. Pointer extend example

Number pyramid

Q. Write a C program to print the following number pyramid.
or
Q. write a C program to print the following number triangle.

123456654321
1234554321
12344321
123321
1221
11

Ans.

/*c program for print the number pyramid*/
#include<stdio.h>
#include<conio.h>
int main()
{
  int num,i,j,n,r;
  printf("Enter number of rows: ");
  scanf("%d", &num);
  n = num;
  printf("\n");
  for(r=1; r<=num; r++,n--)
  {
     for(i=1; i<=n; i++)
         printf("%d",i);
     for(j=n; j>=1; j--)
         printf("%d",j);
     printf("\n");
  }
  getch();
  return 0;
}

/****************************************************

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

Output of number pyramid C program
Figure: Screen shot for number pyramid C program


Related Programs:

Q. Write a C program to print the following character pyramid.

       ABCDEFFEDCBA
       ABCDEEDCBA
       ABCDDCBA
       ABCCBA
       ABBA
       AA

You might also like:

  1. Big 98+ C pyramid programs list
  2. Latest user asking pyramid programs list



Character Pyramid

Q. Write a C program for following character triangle.
or
Q. Write a C program for print the following character pyramid.

ABCDEFFEDCBA
ABCDEEDCBA
ABCDDCBA
ABCCBA
ABBA
AA

Ans.

/*c program for character triangle pyramid*/
#include<stdio.h>
#include<conio.h>
int main()
{
 char ch,r,c,m,p;
 printf("Enter any character: ");
 scanf("%c", &ch);
 if(ch>='a' && ch<='z')
    ch = ch-32;
 c=ch;
 printf("\n");
 for(r='A'; r<=ch; r++,c--)
 {
    for(m='A'; m<=c; m++)
        printf("%c",m);
    for(p=c; p>='A'; p--)
        printf("%c",p);
    printf("\n");
 }
 getch();
 return 0;
}


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

Output of character pyramid C program
Figure: Screen shot for character pyramid C program

Related Programs:

Q. Write a C program to print the for following number triangle:

       123456654321
       1234554321
       12344321
       123321
       1221
       11


You Might Also Like:

  1. Big 98+ C pyramid programs list
  2. Latest user asking pyramid programs list