#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();
gotoxy(X,X);
textcolor(BLUE);
cprintf("%s",str);
for(i=0;i<l;i++)
{
temp=*(str+i);
gotoxy(X+i,X);
printf(" ");
for(j=X;j<50;j++)
{
gotoxy(X+i,j);
z=random(color);
textcolor(z);
cprintf("%c",temp);
delay(100);
gotoxy(X+i,j);
printf(" ");
}
}
getch();
}
You are the cause of my pain
You are the cause of my pain, yet the love I feel for you is my only consolation, my only cure..
Saw the girl, whom once I thought as my best friend
Remembering my classmates, after few years, My eyes were filled with tears, Everyone is busy a lot, No one escaped destiny's plot, Saw the girl, whom once I thought as my best friend, Today she is some body else's girl friend, After months remembered about her for a little while, Heard she is happy, that made me smile.
It’s been raining since you left me
It’s been raining since you left me, now I’m drowning in the flood. You see, I’ve always been a fighter, but without you I give up.
Sweet Heart
Sweetheart.....I miss ......THe whisper of your voice...The warmth of your touch and all the wonderful times that we shared together.......
When I see you
When I see you smile and know that it's not for me, that's when I miss you the most.
Create EID greetings in C Program
Create your own Love-Meter using C programming.
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);
cprintf("\n\n\n\n Welcome To Love-Meter\n");
textcolor(2);
cprintf("* ---------------- * --------------*\n");
textcolor(3);
cprintf(" enter your name:\n");
scanf("%s",&nm1);
textcolor(5);
cprintf(" enter ur partner's:\n");
scanf("%s",nm2);
i=0;
while(nm1[i]!=0)
{
i++;
a1++;
}
i=0;
while(nm2[i]!=0)
{
i++;
a2++;
}
if(a1>a2)
{
n=a1;
m=a2;
}
else
{
n=a2;
m=a1;
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(nm1[i]==nm2[j])
{
count++;
break;
}
}
}
p=count*100/m;
textcolor(4);
cprintf(" .*'''*.*'''*. ");
cprintf(" * . * ");
cprintf(" * %3d% * ",p);
cprintf(" * * ");
cprintf(" * * ");
cprintf(" * ");
textcolor(9);
cprintf("\n\n\n LOVE percentage is %d%\n",p);
textcolor(10);
cprintf("HaVe A LOVING rElaTiOnShiP");
textcolor(13);
cprintf(" aLL tHe BeSt ...........");
textcolor(14);
cprintf(" \n\n\nto conti. enter 0 or to EXIT 1");
scanf("%d",&sh);
if(sh==0)
goto label;
textcolor(4);
cprintf("\n\n\n\n\n\n\n\n\n\n\n\n\n***** software designed n developed by Solvedcprogram.blogspot.com *****\n\n\n\n\n\n\n\n\n\n\n");
getch();
}
Enjoy C Programming........... :)
Simple way to protect your computer from Viruses and Hackers
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
- Right click on C:Drive(If operating system is installed in C:Drive)---> Properties.
- You will see a new tab as 'Security' click on it!.
- Select User's at 'Group or user name'(You will see all permission on C:Drive)---> Edit it.As per your requirement(Suggestion:Uncheck write permission for all users except Admin)&Apply it .
- Restart it...
C Program to accept a password
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='*'; putch(ch); printf("nn%s",pw); getch(); }
POINTERS
int a, b;b = &a;int a, *b, c;b = &a;c = *b;b contains the address of a and ‘c = *b’ means to use the value in b as an address, i.e., as a pointer. The effect is that we get back the contents of a, albeit rather indirectly. (It’s always the case that ‘*&x’ is thesame as x if x has an address.)
The most frequent use of pointers in C is for walking efficiently along arrays. In fact, in the implementation of an array, the array name represents the address of the zeroth element of the array, so you can’t use it on the left side of an expression. (You can’t change the address of something by assigning to it.) If we say
char *y;char x[100];y is of type pointer to character (although it doesn’t yet point anywhere). We can make y point to an element of x by either of
y = &x[0];y = x;*(y+1) gives x[1]*(y+i) gives x[i]y = &x[0];y++;leaves y pointing at x[1]
Let’s use pointers in a function length that computes how long a character array is. Remember that by convention all character arrays are terminated with a ‘\0’. (And if they aren’t, this program will blow up inevitably.) The old way:
length(s)char s[ ]; {int n;for( n=0; s[n] != ′\0′; )n++;return(n);}length(s)char *s; {int n;for( n=0; *s != ′\0′; s++ )n++;return(n);}for( n=0; *s++ != ′\0′; n++ );strcopy(s,t)char *s, *t; {while(*t++ = *s++);}For arguments to a function, and there only, the declarations
char s[ ];char *s;CREATE NEGATIVE FROM PNG IMAGE
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 {
iname = argv[1];
oname = argv[2];
}
if((fp = fopen(iname, "r")) == NULL)
error(1, 0, "Error - fopen(): %s", iname);
else
img = gdImageCreateFromPng(fp);
w = gdImageSX(img);
h = gdImageSY(img);
for(x = 0; x < w; x++) {
for(y = 0; y < h; y++) {
color = gdImageGetPixel(img, x, y);
red = 255 - gdImageRed(img, color);
green = 255 - gdImageGreen(img, color);
blue = 255 - gdImageBlue(img, color);
color = gdImageColorAllocate(img, red, green, blue);
gdImageSetPixel(img, x, y, color);
}
}
if((fp = fopen(oname, "w")) == NULL)
error(1, 0, "Error - fopen(): %s", oname);
else {
gdImagePng(img, fp);
fclose(fp);
}
gdImageDestroy(img);
return 0;
}BEEPS THE SPEAKER-C SOURCE CODE
/*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 1 for beep 1.\n");
puts("Enter 2 for beep 2.\n");
puts("Enter 3 to quit.\n");
/*scan for user entry*/
scanf("%d", &reply);
return reply;
}
EMPTY RECYCLE BIN USING C PROGRAM
/*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 ;
}
Small C Program-Convert IP address to it's base10 form
/*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 var3 = 0, var4 = 0;
/* any options given ? */ if(argc == 1) print_help(1); /* option parser */ while((opt = getopt(argc, argv, "hvxa")) != -1) { switch(opt) { case 'h': /* print this help and exit */ print_help(0); case 'v': /* print program version and exit */ print_version(0); case 'x': /* output in Hex.. */ print_flag = 1; break; case 'a': /* output some additional info... */ print_flag = 2; break; case '?': /* no such option */ fprintf(stderr, "%s: Error - No such option: `%c'\n\n", PACKAGE, optopt); print_help(1); } }
/* enough options left ? */ if((argc - optind) == 0) print_help(1); /* compile regular expression */ if(regcomp(&re, IPEXPR, REG_EXTENDED) != 0) { fprintf(stderr, "%s: Error - compiling regular expression..\n", PACKAGE); return 1; } /* while parsing remaining opts.. */ for(; optind < argc; optind++) { /* very basic test of ip4 dotted quad address format */ if(regexec(&re, argv[optind], 0, NULL, 0) != 0) { fprintf(stderr, "%s: Error - `%s'; not a ip4 dotted quad..\n" , PACKAGE, argv [optind]); continue; } /* read address */ scanf(argv[optind], "%d.%d.%d.%d", &var1, &var2, &var3, &var4); /* convert address to base 10 */ result = (var1 << 24) + (var2 << 16) + (var3 << 8) + var4; /* output the results */ if(print_flag == 0) printf("%lu\n", result); else if(print_flag == 1) printf("%0lx\n", result); else { printf("%%\n"); printf("ip addr : %s\n", argv[optind]); printf("formula : %d * (256^3) + %d * (256^2) + %d * 256 + %d\n", var1, var2, var3, var4); printf("base10 : %lu\n", result); printf("hex : %0lx\n", result); } } return 0;}void print_help(int exval) { printf("%s,%s convert an IP address to its base10 form\n", PACKAGE, VERSION); printf("Usage: %s [-h] [-v] [-x] [-a] IP IP..\n\n", PACKAGE);
printf(" -h print this help and exit\n"); printf(" -v print version and exit\n"); printf(" -x print address in Hexadecimal\n"); printf(" -a print additional info\n\n");
printf(" Please note, this is valid for IP version 4 addresses only!\n"); exit(exval);}/* print version and exit with exval */void print_version(int exval) { exit(exval);}
Switch Case Statement in C
switch(expression){case value1: /*execute code1*/break;case value2: /*execute code2*/break;.....default: /*execute default action*/break;}/*Program to convert number into word*/#include<stdio.h>void main(){int num;printf("Enter a number:\n");scanf("%d",&num);switch(num){case 1:printf("ONE!\n");break;case 2:printf("TWO!\n");break;case 3:printf("THREE!\n");break;case 4:printf("FOUR!\n");break;case 5:printf("FIVE!\n");break;case 6:printf("SIX!\n");break;case 7:printf("SEVEN!\n");break;case 8:printf("EIGHT!\n");break;case 9:printf("NINE!\n");break;case 0:printf("ZERO!\n");break;default:printf("Invalid Number!\n");break;}getch();}IF statement in C program
Syntax is:
if(expression)
Execute this line of codeExample:
#include<stdio.h>
void main()
{
int number;
printf("Enter the number");
scanf("%d",&number);
if(number<5) /*if number less than five*/
{
printf("The number is less than five");
}
getch():
}I recommended always putting braces following if statements.If you do this,you never have to remember to put them in when you want more than one statement to executed,and you make the body of the if statement more visually clear.
Else
Syntax is:
if(expression is TRUE) { Execute this code }else { Execute this code }Example:
#include<stdio.h>void main(){int num;printf("Enter the number");scanf("%d",&num);if(num==5);{printf("The entered number is 5");}else{printf("The entered number is not 5");}getch():}Else if
Example:
#include<stdio.h>void main(){int num;printf("Enter the number 1 or 2 or 3");scanf("%d",&num);if(num==1){printf("The entered number is one");}else if(num==2){printf("The entered number is two");}else if(num==3){printf("The entered number is three");}else{printf("number is invalid");}getch();}<<Prev Home Next>>
C PROGRAM TO REVERSE A NUMBER USING WHILE LOOP
#include<stdio.h>TO FIND THE SUM OF DIGITS IN A FIVE DIGIT NUMBER
#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();}
How Use Loops in C-'DO WHILE' Loops
'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 as WHILE loop except that the loop body is guaranteed to execute at least once.A WHILE loop says"Loop while the condition is true,and execute this block of code".A DO WHILE loop says"execute this block of code,and then continue to loop while the condition is true". Notice that this loop will execute once,because it automatically execute before checking the condition.<<Prev Home Next>>
How Use Loops in C-'While' Loops
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 so the condition can be met eventually */
}
getchar();
}
This was another example ,but it is longer than FOR loop.The easiest way to think of the loop is that when it reach the brace at the end it jumps back up to the beginning of the loop,which check the condition again and decides whether to repeat the block another time,or stop and move to the next statement after the block.More example using 'while' loop
<<Prev Home Next>>
How Use Loops in C-'FOR' Loops
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;
/* The loop goes while x < 10, and x increases by one every loop*/
for ( x = 0; x < 10; x++ ) {
/* Keep in mind that the loop condition checks
the conditional statement before it loops again.
consequently, when x equals 10 the loop breaks.
x is updated before the condition is checked. */
printf( "%d\n", x );
}
getchar();
}
The variable initialization allows you to either declare a variable and give it a value or give it a value to already existing variable.The condition tells the program that while the conditional expression is true the loop should continue to repeat it self.The variable update section is the easiest way for a FOR loop to handle changing of the variable.It is possible to do things like X++,X=X+10 or even X=random(3).Notice that a semicolon separates each of these sections. Also note that every single one of the sections may be empty,though the semicolon still have to be there
This program is a very simple example of a for loop.x is set to zero,while x is less than 10 it calls printf to display the value of variable x,and it adds 1 to x until the condition is met.Keep in mind also that the variable is incremented after the code in the loop is run for the first time
<<Prev Home Next>>
