Thursday, August 18, 2011

Program to find a number is prime or not

/*Program to find a number is  prime or not*/


#include "stdio.h"

#include "conio.h"

void main()

{

int a,b,c=1;

clrscr();

printf("enter the number : ");

scanf("%d",&a);

for(b=2;b<=(a/2);b++)

{

if(a%b==0)

{

c++;

}

}

if(c>1)

{

printf("not prime");

}

else

{

printf("prime ");

}



getch();

}

OUTPUT : -
enter the number : 17
prime

enter the number : 15
not prime





r u unable to understand this program??????????TRY THESE






1. Email us at chelperr@gmail.com



2. Post your question in the comment box.



3. You can give us your email ID also.



4. If you want to ask a program/topic or wanted introduce any discussion topic then just email at chelperr@gmail.com or drop a comment in the comment box.

Random number generation program



#include "STDIO.H"

#include "STDLIB.H"

#include "TIME.H"

int main()

{

int num;

randomize();

//Generating the random number

num = random(99999);

//Printing the random number

printf("%d",num);


return 0;





r u unable to understand this program??????????TRY THESE


1. Email us at chelperr@gmail.com

2. Post your question in the comment box.

3. You can give us your email ID also.

4. If you want to ask a program/topic or wanted introduce any discussion topic then just email at chelperr@gmail.com or drop a comment in the comment box.

Decimal to binary conversion program

#include "stdio.h"


#include "conio.h"

void main()

{

int num[10];

int i=0,digit;

int n;

clrscr();

printf("enter a decimal number\n");

scanf("%d",&n);

while(n!=0)

{

digit=n%2;

num[i]=digit;

i++;

n=n/2;

}

i--;

printf("binary form: ");

while(i>=0)

{

printf("%d",num[i]);

i--;

}

getch();

}

OUTPUT : -
enter a number in decimal form
10
binary form: 1010


r u unable to understand this program??????????TRY THESE




1. Email us at chelperr@gmail.com

2. Post your question in the comment box.

3. You can give us your email ID also.
4.  If you want to ask a program/topic or wanted introduce any discussion topic then  just email at chelperr@gmail.com or drop a comment in the comment box.

Program to add n digit number e .g 123 = 6 or 4567 = 21 etc

#include "stdio.h''


#include ''conio.h''

main() {

signed long int num,sum=0,digit;



printf("enter digits = ");

scanf("%ld",&num);





while(num%10) {



digit=num%10;

sum+=digit;

num/=10;



}



printf("Digit sum = %ld",sum);



getch();

}
 
 
OUTPUT : -
 
enter digits = 123
Digit sum = 6
 
enter digits = 123456789
Digit sum = 45
 
r u unable to understand this program??????????TRY THESE
 
1. Email us at chelperr@gmail.com
2. Post your question in the comment box.
3. You can give us your email ID also.

Sunday, August 14, 2011

Bubble sorting in C

#include "stdio.h"


#include "conio.h"

void main()

{

int arr[100],temp,i,n,j;

clrscr();

printf("\nEnter number of elements in array less Than 100 : ");

scanf("%d",&n);

printf("\n\tEnter The Values into ARRAY ");

for(i=0;i

{

printf("\n\n Enter Element no %d: ",i+1);

scanf("%d",&arr[i]);

}

for(i=0;i

{

for(j=0;j

{

if(arr[j] >arr[j+1])

{

temp=arr[j];

arr[j]=arr[j+1];

arr[j+1]=temp;

}

}

}

printf("\n\n-- Sorted Series --");

for(i=0;i

{

printf("\n \n \t %d",arr[i]);

}

getch();





}
 
OUTPUT : -
 
Enter number of elements in array less than 100 : 5
                   
                            Enter the values into ARRAY
Enter element no 1 : 8
 
Enter element no 2 : -6
 
Enter element no 3 : 0
 
Enter element no 4 : 1
 
Enter element no 5: 9
 
--Sorted Series--
         -6
          0
          1
          8
          9

Program to Create A human face which smiles and cries

#include "graphics.h"


#include "stdlib.h"

#include "stdio.h"

#include "malloc.h"

#include "dos.h"

#include "conio.h"



int xasp,yasp,gdriver = VGA, gmode=VGAMED, errorcode;



struct pos

{

int x;

int y;

};



struct face

{

int radius;

struct pos position;

int mood;

};



typedef struct face face;

face *face1;



void getposition()

{

printf("Enter X Co-ordinate:");

scanf("%d",&face1->position.x);

printf("Enter X Co-ordinate:");

scanf("%d",&face1->position.y);

}



void drawface()

{



char ch='x';

int i=0,x,y,color,r,imgsize,dif;



x=face1->position.x=320;

y=face1->position.y=180;

face1->radius=150;

color=15;

r=face1->radius;



setbkcolor(0);

getaspectratio(&xasp,&yasp);

setcolor(8);

circle(x,y,face1->radius);



setfillstyle(1,color);

floodfill(x,y,getcolor());





draweyes(face1);

drawhair(face1);

drawmouth(face1);

drawnose(face1);





}



drawnose()

{

int i,x,y,r;

x=face1->position.x;

y=face1->position.y;

r=face1->radius;

setcolor(0);



for(i=0;i<2;i++) r="face1-">radius;

x1=face1->position.x-r/2;

y1=face1->position.y-r/4;

x2=face1->position.x+r/2;

y2=face1->position.y-r/4;



setaspectratio(xasp/2,yasp);

arc(x1,y1-r/8,40,140,r/4);//left eyebrow

arc(x1,y1-r/8+1,40,140,r/4);//left eyebrow

arc(x1,y1-r/8+2,40,140,r/4);//left eyebrow

setaspectratio(xasp,yasp);



for(i=0;i<2;i++) i="0;i<2;i++)" x="face1-">position.x;

y=face1->position.y+(face1->radius/1.5);

r=face1->radius;

setcolor(BLACK);



if((face1->mood)==1)

for(i=0;i<4;i++)>mood)==0)

for(i=0;i<4;i++) r="face1-">radius;

x=face1->position.x-r/2;

y=face1->position.y-r/3;



arc(x,y,34,225,100);



arc(x+r,y,314,138,100);



setfillstyle(1,RED);

floodfill(x,y-70,getcolor());

floodfill(x+r,y-70,getcolor());

setaspectratio(xasp,yasp);

}



void main(void)

{

int i=0;

initgraph(&gdriver, &gmode,"");



while(!kbhit())

{

if((i%2)==1)

{

setvisualpage(1);

setactivepage(0);

clearviewport();

face1->mood=0;

drawface();

delay(1000);

}

else

{

setvisualpage(0);

setactivepage(1);

clearviewport();

face1->mood=1;

drawface();

delay(300);

}

i++;

}



getch();

closegraph();

Friday, January 14, 2011

Frankly speaking,a person is not able to learn/master a programming language




by a book/blog or by doing language classes/lectures.



He/She can only be able to master that language by theirselves.



Actually,what you want to know not book/blog trying to teach.



This blog "Advanced C" is developed with the motive of self exploration.



you should explore yourself that where r u finding the problem/what



things you are not able to understand/how much or upto which level you



want to know the things.



you have nothing to do just email us your questions on chelperr@gmail.com



and we are commited to answer your questions as soon as possible on our blog.



you not need to worry at all we provide your answers to your email also.





NOTE::::JUST BE OUR REGULAR VISITOR TO GET YOUR ANSWERS UP TO DATE.



ALWAYS LEAVE COMMENTS FOR EVERY POST YOU HAVE SEEN OR FOR



SUGGESTIONS OR IMPROVEMENTS.



BE OUR FOLLOWER AND REGULAR VISITOR MAKE COMMENTS TO

GET WHAT U WANT.







:welcome all the visitors



:::c helper: