Monday, August 29, 2011

Create EID greetings in C Program

0 comments
Source Code: #include<stdio.h> #include<conio.h> #include<dos.h> #include<string.h> #include<stdlib.h> #define X 25 void main() {          int i,j,l,t,color=10,z;          char temp;          char* str="Eid Mubarak!";   /*You can change the text here what ever you want to print*/          clrscr();          gotoxy(X,X-1);          l=strlen(str);          clrscr();       ...
Continue reading →
Sunday, August 28, 2011

Create your own Love-Meter using C programming.

0 comments
Create your own love-meter.Copy and paste the below code into your C compiler(Recommended:Borland C).Then compile and execute the file. Source Code: #include<stdlib.h> #include<stdio.h> #include<graphics.h> main() {  int sh,q,w,i=0,j=0,k,a1,a2,count,n,m,l,p,x,y,z,gm,gn;     char nm1[20],nm2[20];     clrscr();     label:clrscr();     a1=0;     a2=0;     count=0;     textcolor(4);     cprintf("__________________________________________");     i=0;     textcolor(1);   ...
Continue reading →
Thursday, August 25, 2011

Simple way to protect your computer from Viruses and Hackers

1 comments
How do you protect your computer from viruses and hackers?. Here is the simple step to prevent attack from viruses and hackers.. This trick will against hackers and viruses. CAUTION:You must be admin or must have admin privileges. Step 1: Go to 'Folder option' in 'control panel'---> 'View tab' Uncheck 'Use Simple file sharing'---> Apply and OK Step 2: Right click on C:Drive(If operating system is installed in C:Drive)---> Properties. You ...
Continue reading →
Wednesday, August 24, 2011

C Program to accept a password

0 comments
This is a simple login C Program.While accepting password it makes each character using "*" symbol and display the password in the next line after the user hits the enter key.It also accept backspace and acts accordingly. SOURCE CODE: # include<stdio.h> #include<conio.h> char pw[25],ch; int i; void main(); { clrscr(); puts("Enter your Password"); while(1) { if(i<0)  i=0;  ch=qetch();  if(ch==13)  break;  if(ch==8)  {  putch('b');  putch(null);  putch('b');  -i;  continue;  }  pw[i++]=ch;  ch='*';&nb ...
Continue reading →
Tuesday, July 12, 2011

POINTERS

0 comments
A pointer in C is the address of something. It is a rare case indeed when we care what the specific address itself is, but pointers are a quite common way to get at the contents of something. The unary operator ‘&’ is used to produce the address of an object, if it has one. Thus int a, b; b = &a; puts the address of a into b We can’t do much with it except print it or pass it to some other routine, because we haven’t given b the right kind of declaration. But if we declare that b is indeed a pointer to an integer, we’re in good shape: int a, *b, c; b = &a; c = *b; b contains ...
Continue reading →

CREATE NEGATIVE FROM PNG IMAGE

0 comments
HI,here we will discuss about how we can create a negative image from png image by using C program.The source code of C Program is given below.Just try it. SOURCE CODE /*CREATE NEGATIVE FROM PNG IMAGE*/ #include <stdio.h> #include <error.h> #include <gd.h> int main(int argc, char *argv[]) {  FILE *fp = {0};  gdImagePtr img;  char *iname = NULL;  char *oname = NULL;  int color, x, y, w, h;  int red, green, blue;  color = x = y = w = h = 0;  red = green = blue = 0;  if(argc != 3)   error(1, 0, "Usage: gdnegat input.png output.png");  else ...
Continue reading →
Saturday, July 9, 2011

BEEPS THE SPEAKER-C SOURCE CODE

0 comments
/*Beeps the speaker using C program*/ #include <dos.h> #include <stdio.h> #include <stdlib.h> int menu(void); main() { while(1) { /*get selection and execute the relevant statement*/ switch(menu()) { case 1: { puts("sound the speaker 1\n"); sound(2000); sleep(2); nosound(); break; } case 2: { puts("sound that speaker 2\n"); sound(4000); sleep(2); nosound(); break; } case 3: { puts("You are quitting\n"); exit(0); break; } default: { puts("Invalid menu choice\n"); break; } } } return 0; } /*menu function*/ int menu(void) { int reply; /*display menu options*/ puts("Enter ...
Continue reading →

EMPTY RECYCLE BIN USING C PROGRAM

0 comments
/*Source code of C program--EMPTY RECYCLE BIN*/ #include<stdio.h> #include<windows.h> #include<shlobj.h> #define WIN32_LEAN_AND_MEAN int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { if(MessageBox(NULL, "Press ok to empty the Recycle Bin.", "recycler", MB_YESNO | MB_ICONINFORMATION) != IDYES) return FALSE; SHEmptyRecycleBin(NULL, "", 0); return FALSE ; } ...
Continue reading →
Saturday, July 2, 2011

Small C Program-Convert IP address to it's base10 form

0 comments
/*SOURCE CODE OF SIMPLE PROGRAM--CONVERT IP ADRESS TO IT'S BASE10 FORM*/ #include<stdio.h> #include<getopt.h> #include<sys/types.h> #include<locale.h> #include<regex.h> #define PACKAGE "ip2b10" #define VERSION "0.0.2" #define URL     "WWW" #define IPEXPR  "([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})" void print_help(int exval); void print_version(int exval); int main(int argc, char *argv[]) {  regex_t re;  int opt = 0;  int print_flag = 0;  long unsigned int result = 0;  int var1 = 0, var2 = 0;  int ...
Continue reading →
Friday, July 1, 2011

Switch Case Statement in C

0 comments
                    The switch case statement allows you to select from multiple choice based on a set of fixed value for a give expression.The value of the variable given into switch is compared to the value following each of the cases.And when one value matches the value of the variable,the computer continues executing the program from that point. Syntax of the 'switch case' statement is: switch(expression) { case value1:  /*execute code1*/ break; case value2: /*execute code2*/ break; ..... default: /*execute default action*/ break; } Example: /*Program ...
Continue reading →
Tuesday, June 28, 2011

IF statement in C program

0 comments
                    The if statement controls conditional branching.The body of an if statement is executed if the value of the expression is nonzero.The if statement allows you to control if a program enters a section of code or nor based on whether a given condition is true or false.One of the important function of the if statement is that it allows the program to select an action based upon the user's input.For example we can check user entered password by using if statement,and decide whether a user is allowed access to the program.  Syntax ...
Continue reading →

C PROGRAM TO REVERSE A NUMBER USING WHILE LOOP

2 comments
/*Program to reverse a number using while loop*/#include<stdio.h>void main(){long int number,reverse,n;clrscr();printf("Enter the number");scanf("%ld",&number);reverse=0;while(number!=0){n=number%10;reverse=reverse*10+n;number=number/10;}printf("The reverse number=%ld\n",reverse);getch( ...
Continue reading →

TO FIND THE SUM OF DIGITS IN A FIVE DIGIT NUMBER

0 comments
#include<stdio.h> void main(){int digit_1,digit_2,digit_3,digit_4,digit_5,sum,number,n;printf("Enter a five digit number");scanf("%d",&number);n=number;digit_1=n%10;n=n/10;digit_2=n%10;n=n/10;digit_3=n%10;n=n/10;digit_4=n%10;n=n/10;digit_5=n;sum=digit_1+digit_2+digit_3+digit_4+digit_5;printf("sum of digits=%d\n",sum);getch() ...
Continue reading →
Monday, June 27, 2011

How Use Loops in C-'DO WHILE' Loops

0 comments
'DO WHILE' loops are useful for things that want to loop at least once.The syntax is: do { Code to execute }while(condition); Example: #include<stdio.h> int main() { int x; x=0; do {/*"Hello World!" is printed at least one time even though the condition is false*/ printf("Hello World!"); } while(x!=0); getchar(); } Notice that the condition is tested at the end of the block instead of beginning ,so the block will be executed at least once.If the condition is true,we jump back to the beginning of the block and execute it again.A DO WHILE loop is almost  the same ...
Continue reading →
Sunday, June 26, 2011

How Use Loops in C-'While' Loops

0 comments
WHILE loops are very simple and the syntax is: while(condition) { Code to execute while the condition is true }  The true represent a boolean expression which could be while(x==1) or while(x!=7),x does not equal to 7.It can be any combination of boolean statements that are legal.Even, while(x==5||y==7) which says execute the code while x equal to 5 or y equal to 7. Example: To print numbers up to 10: #include<stdio.h> int main() { int x=0;  /*Don't forget to declare variables*/ while(x<10) /*while x less than 10*/ { printf("%d",x); x++; /*Update x ...
Continue reading →

How Use Loops in C-'FOR' Loops

0 comments
Loops are used to repeat a block of code.Loops are one of the most basic but useful task in programming.We can simply produce extremely complex out put using loops.A loops let you write a very simple statement to produce a significantly greater result  simply by repetition. FOR LOOPS: FOR loops are the most useful one.The syntax of FOR loops: for(variable initialization; condition; variable update) { code to execute while the condition is true } Example: To print numbers upto 10: #include<stdio.h> int main() {     int x;     /* ...
Continue reading →