Feb 27, 2007

C++ program to find odd numbers between 1 to 100

C++ program to find odd numbers between 1 to 100
// In this C++ program the for loop is generating a number from 1 to 100
// and increment by 1. In loop the program will check each number whether
// it is odd or not by taking a%2!=0. If result of a mod 2 is not equals to 0
// means number is odd and it will get printed by cout statement
#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int a;
for (a=1;a<=100;a++)
{
if (a%2!=0)
{
cout << a <<endl;
}
}
getch();
}

C++ program to find even numbers between 1 to 100

// In this C++ program the for loop is generating a number from 1 to 100
// and increment by 1. In loop the program will check each number whether
// it is even or not by taking a%2==0. If result of a mod 2 is equals to 0
// means number is even and it will get printed by cout statement
#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int a;
for (a=1;a<=100;a++)
{
if (a%2!=0)
{
cout << a <<endl;
}
}
getch();
}

Feb 26, 2007

C++ program to generate a melodious sound from PC speaker

C++ program to generate a melodious sound from PC speaker. For this purpose sound() function, delay() function and nosound() function are used. For these functions a special header file dos.h is included.
#include<iostream.h>
#include<conio.h>
#include<dos.h>
main()
{
clrscr();
for(int i=100;i<=1000;i=i+100)
{
sound(i);
delay(500); // time delay in milliseconds
nosound(); // it will stop the sound
}
getch();
}

C++ program to generate a beep sound from the PC speaker

C++ program to generate beep sound. Here for this purpose dos.h header file is used. In this program sound() function, delay() function and nosound() function are used.This program will generate beep sound from the PC speaker.
#include<iostream.h>
#include<conio.h>
#include<dos.h>
main()
{
clrscr();
sound(500); // 500 is frequency
delay(1000); // time delay in milliseconds
nosound(); // it will stop the sound
getch();
}

Feb 24, 2007

C program to generate a pyramid of stars (upside down )

C program to generate pyramid of stars upside down using for loop.
#include<stdio.h>
main()
{
int a,b,c;
a=1;
clrscr();
for (a=5;a>=1;a--)
{
for (b=a;b>=1;b--)
{
printf("*");
}
printf("\n");
}
getch();
}
//output would be
*****
****
***
**
*

C program to generate a pyramid of stars

C program to generate pyramid of stars using for loop. In this program we use nesting of loop. Here two loops are used.
#include<stdio.h>
main()
{
int a,b,c;
a=1;
clrscr();
for (a=1;a<=5;a++)
{
for (b=1;b<=a;b++)
{
printf("*");
}
printf("\n");
}
getch();
}
//output would be
*
**
***
****
*****

C program to generate a table of any given number

C program to generate table of any given number using while loop.
#include<stdio.h>
main()
{
int a,b,c;
a=1;
clrscr();
printf("Enter Any No.");
scanf("%d",&b);
while (a<=10)
{
c=a*b;
printf("\n%d",c);
a=a+1;
}
getch();
}

C program to generate odd numbers

C program  to generate odd numbers using while loop.

#include<stdio.h>
main()
{
int a=1;
clrscr();
while (a<20)
{
printf("\n%d",a);
a=a+2;
}
getch();
}

C program to generate even numbers

C program to generate even numbers using while loop.
#include<stdio.h>
main()
{
int a=0;
clrscr();
while (a<20)
{
a=a+2;
printf("\n%d",a);
}
getch();
}

C program to generate natrual numbers from 1 to 100

C program to generate natural numbers from 1 to 100 using while loop.
#include<stdio.h>
main()
{
int a=1;
clrscr();
while (a<=100)
{
printf("\n%d",a);
a=a+1;
}
getch();
}

C++ Program to swap two numbers

C++ program to swap to numbers (integers) means this program will accept two numbers and it interchange their values.
#include<iostream.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
a=20;
b=50;
cout<<a;
cout<<endl<<b;
c=a;
a=b;
b=c;
cout<<endl<<"Now a is : = "<<a;
cout<<endl<<"And Now b is : = "<<b;
getch();
}

Creating picture package in Photoshop: (Tutorial)

Professional photographers always need a method to make an array of passport photo or we may say picture package of passport photo. Here I am explaining step by step process to do the same thing.

Scanning a photograph:
Step 1: Scan the photograph for which you want to make a picture package by your scanner and save the scanned image file.

Step 2: Open the scanned image file in Photoshop.

Resizing the image:
Step 3: Now change the image size by clicking “Image menu > Image size”. Image size dialogue box will be appeared on the screen. Set the Document size type in width as 2 and height as 3 inches and set the resolution as 200. Before doing this also uncheck the Constrain Proportion checkbox and then press “Ok” button to resize the image. For more details on how to resize the image click here and read. After resizing the image your image should look like this.

Making a border around the photo:
Step 4: Now Click “Select menu > All” to select the entire image. Now click “Edit > Stroke”, Stroke dialogue box will be appeared on the screen.

Step 5: Now type in stroke width 5 px and choose Color of stroke as white and choose Stroke Location is “Inside” and Blending mode is normal, Opacity is 100% and then press “Ok” button. Now the image will be looked like the following picture.

Defining a pattern of image:
Step 6: Now click “Select > All” to select the entire image again and then click “Edit > Define Pattern”. “Define Pattern” dialogue box will be appeared on the screen. It asks for name of the pattern which you want to create. Type in a desired name there and press “Ok” button to close the window. Now we have successfully created a pattern.

Creating Package of defined pattern:
Step 7: Now click “File > New” to create a new file. New file dialogue box will be appeared on the screen set width as 8 inches and height as 12 inches and resolution of the image as 200 pixels/inch and then press “Ok” button. A blank 8x12 inches page will be appeared on the screen.
Here you may see that we have created a blank page of size 8 width and 12 height and our image size is 2x3 means 2 inches width and 3 inches height so that photo array will be 4x4 means total 16 passport photos. By this way you can calculate the measurement by your requirement and alter the above sizes.

Step 8: Click “Edit > Fill” then Fill dialogue box will be appeared on the screen. Choose “Pattern” from the Use drop down list box and Choose your define pattern from Custom pattern drop down list box. You may find newly created pattern at the end of the custom pattern list. Leave the opacity to 100% and Blending mode as normal and then press “Ok” button to fill the created pattern in blank page and you are done.
Hope that you will like this method. If you face any difficulty you can feel free to mail me.
Read other article to create picture package in Photoshop.

Technorati Tags : , , ,

Rotating Canvas in Photoshop:

If you have image that is not straight, by rotating canvas you can make it straight or you can rotate the image by giving some angle. You can also flip the image horizontally or vertically. If by mistake you have scanned an image horizontally you need it vertically so this tool will be helpful to you.

Origional

Rotating an image 180 degree:
Step 1: To rotate an image click “Image menu > Rotate Canvas > 180. Image would be upside down as shown in the following picture. This should be helpful to you if you scanned an image upside down. So by rotating 180 degree problem will be solved.

After Rotating an image 180 Degree

Rotating an image 90 degree CW:
To do so click “Image menu> Rotate Canvas > 90 CW”.

After Rotating an image 90 Degree Clockwise

Rotating an image 90 degree CCW:
To do so click “Image menu> Rotate Canvas > 90 CCW”

After Rotating an image 90 Degree Counter Clockwise

Rotating an image arbitrary:
To do so click “Image menu > Rotate Canvas > Arbitrary”. A dialogue box will be appeared on the screen as shown below.

Through this you can rotate an image by giving appropriate angle. Type in 25 in Angle textbox and choose radio button that you want to rotate the image CW (Clock wise) or CCW (Counter Clock wise). Here I am choosing CW and press “Ok” button to see the result.

Flipping Image Horizontally:
To do so click “Image menu> Rotate Canvas> Flip Horizontal”.
Flipping Image Vertically:
To do so click “Image menu> Rotate Canvas>Flip Vertical”.

Technorati Tags : , ,

Feb 23, 2007

Creating Backgrounds in Photoshop: (Tutorial)

In this tutorial we will see that how to create a new file and create background in Photoshop using fill.

You can create special background for your photograph using Fill option in Photoshop.

Step 1: Start Photoshop.
Step 2: Click “File > New’. New Dialogue box will be appeared on the screen.

You can give following things in new dialogue box.

* Name of the Image file
* Size of the image in width and height
* Resolution of the image
* Mode of colors
* Content in the image file

Name Of the Image File:
In name textbox type in an appropriate name of the image file you want.

Size of the image in width and height:
You can also specify size of the image in width and height by typing in their textboxes. Size of the image could be in inches, cm, pixels etc.

Resolution of the image:

Here you can specify resolution of the image whether it is 300, 400 or 600 choose the appropriate one.

Mode of colors:
Choose RGB color from the drop down list box.

Content in the image file:
In Content drop down, Choose “White” if you want to fill background with white. Choose “Background Color” if you want to fill the new file with Background color. This background color can be set from the toolbox as shown below.


When you click “set background color” button as marked in the above picture to change the background color a “Color Picker” dialogue box will be appeared on the screen. Choose the appropriate color for your background and then press “Ok” button to close the Color Picker dialogue box.

Choose “Transparent” if you want to remain the background transparent.

Step 3: then press “OK” button.

"White" Background Fill

"Backgroud Color" Background Fill

"Transparent" Background Fill

Step 4: Click “Edit > Fill”. Fill Dialogue box will be appeared on the screen.

There are many option that you can fill in the background of your image.
You can fill

Foreground color
Background color
Pattern
History
Black
50% Gray
White

Foreground and Background colors are which you set from the toolbox.

Step 5: Now choose “Pattern” from the “use” drop down list box. Custom pattern drop down list box will get activate. Now choose any one pattern of your choice from the list. And then choose “Mode” as normal. Now you can specify opacity in percentage. What actually opacity is. Opacity means if you specify 100%, then background would be 100% opaque and 0% opacity means the background would be completely transparent.

Step 6: Leave opacity at 100% and press “Ok” button.

Now try with different opacity and do the experiment with fill.

You can change custom patterns by doing the following steps.

Click “Edit > Fill > Custom Pattern”. Now click the button as shown in the following picture.
A popup menu will be appeared on the screen choose “pattern2.pat” or “patterns.pat” from the popup menu. A confirmation window will be appeared on the screen press “Ok” to load the pattern in the custom pattern.

Now you can use newly loaded custom patterns for your background. We can also create user defined patterns in Photoshop by defining new patterns. I will write on this in my forthcoming post.

Technorati Tags : , , ,

Feb 22, 2007

Sharpen Filter in Photoshop

This is the one of the best Photoshop filter. If you have some images that is out of focus you can repair them with Sharpen filter in Photoshop up to some level.

Step 1: Open photo in Photoshop which is out of focus.


Origional Image

Step 2: Then click “Filter > Sharpen > Sharpen. The image will be sharp. If you need more sharpen then click “Filter > Sharpen > Sharpen More”. After applying sharpen effect image will be looked like this.

After Applying Sharpen More Filter

Step 3: Click “Filter > Sharpen > Sharpen Edges” then only edges of the image will be get shaped as shown in the following picture.

After Applying Sharpen Edges Filter

Technorati Tags : , ,

Changing canvas size in Photoshop

By changing canvas size you can increase area around the image. It does not change the size of the image. It gives us extra working space around the image. To do so

Step 1: open the scanned image or snap you have taken by your digital camera.


Step 2: Click “Image > Canvas Size”. “Canvas size” dialogue box will be appeared on the screen.

This dialogue box shows the current size of the image. It is now showing 10.667 width and 7.111 height. By changing width and height, you can change the canvas size.

Step 3: Type 13 as a width and 10 as a height. Now the will be looked like this.

You can also reduce this width and height so that image will be cropped.

Anchor shows that where you want to put the image after changing the size of the canvas. You can also set the position of the photo by clicking desired anchor point. But by default it is set to the center.

Step 4: Change the anchor point to upper left corner so the image will be place on the upper left corner.


Technorati Tags : , , ,

Feb 21, 2007

Color photograph into Grayscale in Photoshop :

Step 1: Open your color photo in Photoshop.

Step 2: then click “Image > Mode > Grayscale”. A confirmation window will be appeared on the screen. It will ask you that all color information in the photo will be discarded.

Step 3: Press “Ok” button and you are done. Your color photograph will be converted in a Grayscale image.

Technorati Tags : , , ,

Adjusting Brightness and Contrast in Photoshop: (Tutorial)

If you have scanned an image or take a snap by your digital camera and unfortunately that is too dark. So there is an option of adjusting brightness and contrast in Photoshop. Just open your scanned image in Photoshop.

Before Adjusting Brightness/Contrast


Click image > Adjust > Brightness/Contrast. “Brightness/Contrast” window will be appeared on the screen. Now adjust the brightness/contrast slider of the window. Also make sure that “Preview” Checkbox is checked. See the result when you are adjusting brightness/contrast then press “Ok” button when you are done.

After Adjusting Brightness/Contrast


Also there is an option to set the contrast of an image automatically. For that click “Image>Adjust>Auto Contrast”. Use this feature if you don’t have enough time to set the Brightness/Contrast of a picture.

Technorati Tags: , , , ,

How To Resize Picture in Photoshop (Enlarge or Reduce Images):

Sometimes we need to resize image. Whether it may be to enlarge or reduce the size of photo. We can easily achieve the same thing in Photoshop. Follow this process, which is given below.

Step 1: Open the photo file, which is to be reduced or enlarged in Photoshop.
Step 2: Click “Image” Menu then, Choose “Image Size” from the menu options.
Step 3: “Image Size” dialogue box will be appeared on the screen.


“Image Size” dialogue box shows size of image. In the case of above picture Its pixel dimension shows width of the image is “888” pixels and height of the image is “1200” pixels. This image size can be changed.

Step 4: Change its width to “400” pixels by typing in its width text box. Only width of image will be changed as shown in the following photo.


If we want to change size of the photo in proportion, check the “Constrain Proportion” Check box. Then change the size o the photo, now photo will be resized in proportion.

Pixel dimension shows the size of photo in pixel by default. We can change this in “Percent” by selecting “Percent” option from the drop down list along with width and height text box. By default it shows the size of image is 100 percent width and 100 percent height. We can change this to any percent of our choice. If we want it the half of the current size set it to 50 percent. If we want the size of image is double the current one then set it to 200 percent. By this way we can enlarged or reduce the size of image easily.

“Image size” dialogue box also shows “Document size”. There we can give size of image in inches, cm, point etc. Type width and height of the image in inches, cm or point according to your need.

In “Image size” dialogue box, you can also set resolution of the image.

Technorati Tags : , , ,

Feb 3, 2007

C++ Program to generate table of any given number

C++ Program to generate table of any given number. This program accepts a input from the user and generate a table of given number.

main()
{
clrscr();
int num;
cout <<"enter any number";
cin >> num;
for (int i=1;i<=10;i++)
{
cout << num * i <<endl;
}
getch();
}