Posts

Showing posts with the label c Program

Ranibow design in c Language

Image
C Program to  Create rainbow #include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> void main() { int gdriver = DETECT,gmode; int x,y,i;     initgraph(&gdriver,&gmode,"C:\\Turboc3\\BGI");     x=getmaxx()/2;     y=getmaxy()/2;     for(i=30;i<200;i++)     {         delay(100);         setcolor(i/10);         arc(x,y,0,180,i-10);     } getch(); } Out put

Circle in C graphics

Image
C Program to  Draw Circle  #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> int main(void) {    /* request auto detection */    int gdriver = DETECT, gmode, errorcode;    int midx, midy;    int radius = 100;    /* initialize graphics and local variables */    initgraph(&gdriver, &gmode, "C:\\turboc3\\bgi");    /* read result of initialization */    errorcode = graphresult();    if (errorcode != grOk)  /* an error occurred */    {       printf("Graphics error: %s\n", grapherrormsg(errorcode));       printf("Press any key to halt:");       getch();       exit(1); /* terminate with an error code */    }    midx = getmaxx() / 2;    midy = getmaxy() / 2; ...

C Program to check prime number

Image
C Program to  check prime number  #include<conio.h> #include<stdio.h> void main() {     int p,i;     clrscr();     printf("enter no. to check prime: ");     scanf("%d",&p);     for(i=2;i<p;i++)     if(p%i==0)     {         printf("%d is not a prime number ",p);         break;     }     if(i==p)     printf("%d is prime number",p);     getch(); } Explanation int p,i;       p and i are two variables of integer type ; printf() and scanf() are predefine functions use for read and write respectively. for(i=2;i<p;i++) for loop use to check prime number  count  if(p%i== 0) if p % i = 0 then it means 'p' has any common factor between 1 to p which means it is not a prime...

Perform looping with if statement.

Image
C Program to  create if loop #include<conio.h> #include<stdio.h> void main() {     int i,j,k,l=1;     clrscr();     i=1;     i1:     if(i<=5)     {         j=4;         j1:         if(j>=i)         {             printf(" ");             j--;             goto j1;         }         k=1;         k1:         if(k<=l)         {             printf("*");             k...

C Program Check even and odd input

Image
C Program  Check even and odd input #include<conio.h> #include<stdio.h> void main() {     int num1;     clrscr();     printf("Enter number : ");     scanf("%d",&num1);     if(num1%2==0)     printf("%d is Even number ",num1);     else     printf("%d is odd number ",num1);     getch(); } Output:

Find Factorial of any number

Image
C Program to Find Factorial of any number #include<conio.h> #include<stdio.h> void main() {     int number,fact,i;     clrscr();     printf("Enter Number : ");     scanf("%d",&number);     fact=1;     for(i=1;i<=number;i++)     {         fact=fact*i;     }     printf("factorial of %d is : %d",number,fact);     getch(); } Output:  

Swapping of Two number

Image
C Program to Swapping of Two number #include<conio.h> #include<stdio.h> void main() {     int num1,num2,temp=0;     clrscr();     printf("Enter first number : ");     scanf("%d",&num1);     printf("Enter second number : ");     scanf("%d",&num2);     printf("\n\nValue of A: %d   and  Value of B: %d",num1,num2);     temp=num1;     num1=num2;     num2=temp;     printf("\n\n\n After swaping \n\n");     printf("Value of A: %d   and  Value of B: %d",num1,num2);     getch(); } out put

Print table of any number

Image
C Program to Print table of any number #include<conio.h> #include<stdio.h> void main() {     int n ,i;     clrscr();     printf("Enter Number for Table print: ");     scanf("%d",&n);     for(i=1;i<=10;i++)     {         printf("\n %d x %d = %d",n,i,n*i);     }     getch(); } out put :  

Add two integer numbers with user input

Program to add two integer numbers and give number at run-time #include<conio.h> #include<stdio.h> void main() { int number1, number 2; clrscr(); printf("Enter First Integer number : "); scanf("%d", &number1); printf("Enter Second Integer number : "); scanf("%d", &number2); printf( " Sum of %d and %d is %d" ,number1,number2,number1+number1); getch(); }

Addition of Two number.

Program to add two numbers #include<conio.h> #include<stdio.h> void main() { printf("Sum of Two number 5 and 8 are : " 5 + 8); getch(); }

User Input

Program to give in put through keyboard or Program to give input at run time #include<conio.h> #include<stdio.h> void main() { char name; clrscr(); printf("enter your name : "); scanf("%s ",& name); getch(); } OutPut enter your name : BRIJESH