Posts

Showing posts from May, 2015

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

Swapping two number without 3rd variable

Image
C Program to Swapping two number without 3rd variable #include<conio.h> #include<stdio.h> void main() {     int num1,num2;     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);     num1=num2+num1;     num2=num1-num2;     num1=num1-num2;     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

Hello world

FIRST PROGRAM THE WORLD STARTS.. #include<conio.h> #include<stdio.h> void main() { printf("HELLO WORLD THIS IS MY FIRST PROGRAM"); getch(); } output: HELLO WORLD THIS IS MY FIRST PROGRAM