Thursday 23 July 2015

Write a C Program To Fine Minimum Element From An Array

#include <stdio.h>
 
int main()
{
  int array[100], maximum, size, c, location = 1;
 
  printf("Enter the number of elements in array\n");
  scanf("%d", &size);
 
  printf("Enter %d integers\n", size);
 
  for (c = 0; c < size; c++)
    scanf("%d", &array[c]);
 
  maximum = array[0];
 
  for (c = 1; c < size; c++)
  {
    if (array[c] < maximum)
    {
       maximum  = array[c];
       location = c+1;
    }
  }
 
  printf("Maximum element is present at location %d and it's value is %d.\n", location, maximum);
  return 0;
}

Write a C Program to FInd Maximum Element From An Array

#include <stdio.h>
 
int main()
{
  int array[100], maximum, size, c, location = 1;
 
  printf("Enter the number of elements in array\n");
  scanf("%d", &size);
 
  printf("Enter %d integers\n", size);
 
  for (c = 0; c < size; c++)
    scanf("%d", &array[c]);
 
  maximum = array[0];
 
  for (c = 1; c < size; c++)
  {
    if (array[c] > maximum)
    {
       maximum  = array[c];
       location = c+1;
    }
  }
 
  printf("Maximum element is present at location %d and it's value is %d.\n", location, maximum);
  return 0;
}

Write a C Program To print Summation of Two Number Using Pointer

#include <stdio.h>
 
int main()
{
   int first, second, *p, *q, sum;
 
   printf("Enter two integers to add\n");
   scanf("%d%d", &first, &second);
 
   p = &first;
   q = &second;
 
   sum = *p + *q;
 
   printf("Sum of entered numbers = %d\n",sum);
 
   return 0;
}

Tuesday 21 July 2015

Write a C Program To Find Summation And Multiplication Of Inputed Array Elements

Write a C Program To Find Summation And Multiplication Of Inputed Array Elements
 
#include<stdio.h>
#include<conio.h>

void main()
{
    int i,no[5],n,sum,mul;

    clrscr();
    sum=0;
    mul=1;
    printf("Enter n:");
    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        printf("\nEnter No[%d]:",i);
        scanf("%d",&no[i]);
    }
    for(i=0;i<n;i++)
    {
    sum=sum+no[i];
    mul=mul*no[i];
    printf("\nValue of No[%d]:%d",i,no[i]);
    }
    printf("\nSum : %d",sum);
    printf("\n Multiplication =%d",mul);
    getch();
}

Write a C Program To Convert String in Lowercase Letter

Write a C Program to Convert String in Lowercase Letter

 #include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{

    char nm[10],anm[10];
    clrscr();

    printf("Enter nm:");
    fflush(stdin);
    scanf("%s",nm);

    printf("Lowercase:%s",strlwr(nm));

    getch();
}

Write a C Program To Convert String in Uppercase Letter

Write a C Program To Convert String in Uppercase Letter

WAY=1

 #include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{

    char nm[10],anm[10];
    clrscr();

    printf("Enter nm:");
    fflush(stdin);
    scanf("%s",nm);

    printf("Uppercase:%s",strupr(nm));

    getch();
}


WAY = 2

#include <stdio.h>
#include <string.h>

int main(void)
{
   char *string = "Hello", *ptr;
   clrscr();
   /* converts string to upper case characters */
   ptr = strupr(string);
   printf("%s\n", ptr);
   return 0;
}

Friday 17 July 2015

Write a Java Program to Swaping of Two Numbers, Interchange Two Numbers Java Program Material of MCA

Write a Java Program to Swaping of Two Numbers, Interchange Two Numbers

class prog6
{   
    public static void main(String args[])
    {   
        int a=10,b=20;
       
        a=a+b;
        b=a-b;
        a=a-b;
       
        System.out.println("\n A:"+a);
        System.out.println("\n B:"+b);
       
       
    }
}

Write a Java Program to Perform Addition , Subtraction , Multiplication and Division Java Program Material of MCA

Write a Java Program to Perform Addition , Subtraction , Multiplication and Division
class prog5
{   
    public static void main(String args[])
    {   
        int a=10,b=20,add,sub,mul;
        float div,mod;
        add=a+b;
        sub=a-b;
        mul=a*b;
        div=a/b;
        mod=a%b;
        System.out.println("\n Sum:"+add);
        System.out.println("\n Sub:"+sub);
        System.out.println("\n Mul:"+mul);
        System.out.println("\n Div:"+div);
        System.out.println("\n Module:"+mod);
       
    }
}

Write a Java Program to Find Compound Interest Java Program Material of MCA,BCA,B.E

Write a Java Program to Find Compound Interest

class prog4
{   
    public static void main(String args[])
    {   
        int n=2,p=10000;
        float r=10,ci;
        ci=p*(1+(r/100));
        System.out.println("\n Compound Interest:"+ci);
    }
}

Write a Java Program to Find Simple Interest

Write a Java Program to Find Simple Interest
class prog3
{   
    public static void main(String args[])
    {   
        int n=2,p=10000;
        float r=10,si;
        si=(p*r*n)/100;
        System.out.println("\n Simple Interest:"+si);
    }
}

Write a Java Program to Print Message

Write a Java Program to Print Message
class prog2
{   
    public static void main(String args[])
    {   
        System.out.println("\n Hello ,How Are U ?");
    }
}

Write a Java Program to Print " Hello World " Java Programs Material of MCA

Write a Java Program to Print " Hello World "

class prog1
{   
    public static void main(String args[])
    {   
        System.out.println("\n Hello World");
    }
}

Write a C Program To Find Minimum Element in Array

#include <stdio.h>
 
int main() 
{
    int array[100], minimum, size, c, location = 1;
 
    printf("Enter the number of elements in array\n");
    scanf("%d",&size);
 
    printf("Enter %d integers\n", size);
 
    for ( c = 0 ; c < size ; c++ )
        scanf("%d", &array[c]);
 
    minimum = array[0];
 
    for ( c = 1 ; c < size ; c++ ) 
    {
        if ( array[c] < minimum ) 
        {
           minimum = array[c];
           location = c+1;
        }
    } 
 
    printf("Minimum element is present at location %d and it's value is %d.\n", location, minimum);
    return 0;
}

Write a C Program To FInd Maximum Element in Array

#include <stdio.h>
 
int main()
{
  int array[100], maximum, size, c, location = 1;
 
  printf("Enter the number of elements in array\n");
  scanf("%d", &size);
 
  printf("Enter %d integers\n", size);
 
  for (c = 0; c < size; c++)
    scanf("%d", &array[c]);
 
  maximum = array[0];
 
  for (c = 1; c < size; c++)
  {
    if (array[c] > maximum)
    {
       maximum  = array[c];
       location = c+1;
    }
  }
 
  printf("Maximum element is present at location %d and it's value is %d.\n", location, maximum);
  return 0;
}

Write a C program To Implement Queue (FIFO) First In First Out

#include<stdio.h>
#include<conio.h>
#define MAX 10
int queue[MAX],front=-1,rear=-1;
void insert_element();
void delete_element();
void display_queue();
 
 
int main()
{
  int option;
  printf(">>> c program to implement queue operations <<<");
  do
  {
   printf("\n\n 1.Insert an element");
   printf("\n 2.Delete an element");
   printf("\n 3.Display queue");
   printf("\n 4.Exit");
   printf("\n Enter your choice: ");
   scanf("%d",&option);
   switch(option)
   {
     case 1: insert_element();
              break;
     case 2: delete_element();
             break;
     case 3: display_queue();
             break;
     case 4: return 0;
   }
 
  }while(option!=4);
}
void insert_element()
{
  int num;
  printf("\n Enter the number to be inserted: ");
  scanf("%d",&num);
  if(front==0 && rear==MAX-1)
    printf("\n Queue OverFlow Occured");
  else if(front==-1&&rear==-1)
  {
      front=rear=0;
      queue[rear]=num;
 
  }
  else if(rear==MAX-1 && front!=0)
  {
    rear=0;
    queue[rear]=num;
  }
  else
  {
      rear++;
      queue[rear]=num;
  }
}
void delete_element()
{
  int element;
  if(front==-1)
  {
      printf("\n Underflow");
  }
  element=queue[front];
  if(front==rear)
     front=rear=-1;
  else
  {
    if(front==MAX-1)
      front=0;
    else
      front++;
       printf("\n The deleted element is: %d",element);
  }
 
}
void display_queue()
{
    int i;
    if(front==-1)
      printf("\n No elements to display");
    else
    {
      printf("\n The queue elements are:\n ");
      for(i=front;i<=rear;i++)
      {
          printf("\t %d",queue[i]);
      }
    }
}

Write a C Program To Implement Stack - Last In First Out (LIFO) Method

1:  #include <stdio.h>  
2:  #include <stdlib.h>  
3:  int stack[5];  
4:  void push();  
5:  int pop();  
6:  void traverse();  
7:  int is_empty();  
8:  int top_element();  
9:  int top = 0;  
10:  int main()  
11:  {  
12:    int element, choice;  
13:    for (;;)  
14:    {  
15:     printf("Stack Operations.\n");  
16:     printf("1. Insert into stack (Push operation).\n");  
17:     printf("2. Delete from stack (Pop operation).\n");  
18:     printf("3. Print top element of stack.\n");  
19:     printf("4. Check if stack is empty.\n");  
20:     printf("5. Traverse stack.\n");  
21:     printf("6. Exit.\n");  
22:     printf("Enter your choice.\n");  
23:     scanf("%d",&choice);  
24:     switch (choice)  
25:     {  
26:       case 1:  
27:        if (top == 5)  
28:           printf("Error: Overflow\n\n");  
29:        else {  
30:          printf("Enter the value to insert.\n");  
31:          scanf("%d", &element);  
32:          push(element);  
33:        }  
34:        break;  
35:       case 2:  
36:        if (top == 0)  
37:          printf("Error: Underflow.\n\n");  
38:        else {  
39:          element = pop();  
40:          printf("Element removed from stack is %d.\n", element);  
41:        }  
42:        break;  
43:       case 3:  
44:        if (!is_empty()) {  
45:          element = top_element();  
46:          printf("Element at the top of stack is %d\n\n", element);   
47:        }  
48:        else  
49:          printf("Stack is empty.\n\n");    
50:        break;  
51:       case 4:  
52:        if (is_empty())  
53:          printf("Stack is empty.\n\n");  
54:        else  
55:          printf("Stack is not empty.\n\n");  
56:        break;  
57:       case 5:  
58:        traverse();  
59:        break;  
60:       case 6:  
61:        exit(0);  
62:     }  
63:    }  
64:  }  
65:  void push(int value) {    
66:    stack[top] = value;  
67:    top++;  
68:  }  
69:  int pop() {  
70:    top--;  
71:    return stack[top];  
72:  }    
73:  void traverse() {  
74:    int d;  
75:    if (top == 0) {  
76:     printf("Stack is empty.\n\n");  
77:     return;  
78:    }    
79:    printf("There are %d elements in stack.\n", top);  
80:    for (d = top - 1; d >= 0; d--)  
81:     printf("%d\n", stack[d]);  
82:    printf("\n");  
83:  }   
84:  int is_empty() {  
85:    if (top == 0)  
86:     return 1;  
87:    else  
88:     return 0;  
89:  }  
90:  int top_element() {  
91:    return stack[top-1];  
92:  }  

Monday 13 July 2015

Write C Program to Perform Addition of Two Numbers Using Pointers

1:  #include <stdio.h>  
2:  int main()  
3:  {  
4:    int first, second, *p, *q, sum;  
5:    printf("Enter two integers to add\n");  
6:    scanf("%d%d", &first, &second);  
7:    p = &first;  
8:    q = &second;  
9:    sum = *p + *q;  
10:    printf("Sum of entered numbers = %d\n",sum);  
11:    return 0;  
12:  }  

Write a C Program To Print Fibbonacci Series

1:  #include<stdio.h>  
2:  int main()  
3:  {  
4:    int n, first = 0, second = 1, next, c;  
5:    printf("Enter the number of terms\n");  
6:    scanf("%d",&n);  
7:    printf("First %d terms of Fibonacci series are :-\n",n);  
8:    for ( c = 0 ; c < n ; c++ )  
9:    {  
10:     if ( c <= 1 )  
11:       next = c;  
12:     else  
13:     {  
14:       next = first + second;  
15:       first = second;  
16:       second = next;  
17:     }  
18:     printf("%d\n",next);  
19:    }  
20:    return 0  

Write C Program to Find Armstrong Number

1:  #include <stdio.h>  
2:  int power(int, int);  
3:  int main()  
4:  {  
5:    int n, sum = 0, temp, remainder, digits = 0;  
6:    printf("Input an integer\n");  
7:    scanf("%d", &n);  
8:    temp = n;  
9:    // Count number of digits  
10:    while (temp != 0) {  
11:     digits++;  
12:     temp = temp/10;  
13:    }  
14:    temp = n;  
15:    while (temp != 0) {  
16:     remainder = temp%10;  
17:     sum = sum + power(remainder, digits);  
18:     temp = temp/10;  
19:    }  
20:    if (n == sum)  
21:     printf("%d is an Armstrong number.\n", n);  
22:    else  
23:     printf("%d is not an Armstrong number.\n", n);  
24:    return 0;  
25:  }  
26:  int power(int n, int r) {  
27:    int c, p = 1;  
28:    for (c = 1; c <= r; c++)   
29:     p = p*n;  
30:    return p;    

Write C Program to Find Prime Numbers

#include<stdio.h>
 
int main()
{
   int n, i = 3, count, c;
 
   printf("Enter the number of prime numbers required\n");
   scanf("%d",&n);
 
   if ( n >= 1 )
   {
      printf("First %d prime numbers are :\n",n);
      printf("2\n");
   }
 
   for ( count = 2 ; count <= n ;  )
   {
      for ( c = 2 ; c <= i - 1 ; c++ )
      {
         if ( i%c == 0 )
            break;
      }
      if ( c == i )
      {
         printf("%d\n",i);
         count++;
      }
      i++;
   }
 
   return 0;
}

Write C Program to Print a Pattern

#include <stdio.h>
 
int main()
{
   int row, c, n, temp;
 
   printf("Enter the number of rows in pyramid of stars you wish to see ");
   scanf("%d",&n);
 
   temp = n;
 
   for ( row = 1 ; row <= n ; row++ )
   {
      for ( c = 1 ; c < temp ; c++ )
         printf(" ");
 
      temp--;
 
      for ( c = 1 ; c <= 2*row - 1 ; c++ )
         printf("*");
 
      printf("\n");
   }
 
   return 0;
}

Write C Program to Check Wheather Input Number is Palindram or not

1:  #include <stdio.h>  
2:  int main()  
3:  {  
4:    int n, reverse = 0, temp;  
5:    printf("Enter a number to check if it is a palindrome or not\n");  
6:    scanf("%d",&n);  
7:    temp = n;  
8:    while( temp != 0 )  
9:    {  
10:     reverse = reverse * 10;  
11:     reverse = reverse + temp%10;  
12:     temp = temp/10;  
13:    }  
14:    if ( n == reverse )  
15:     printf("%d is a palindrome number.\n", n);  
16:    else  
17:     printf("%d is not a palindrome number.\n", n);  
18:    return 0;  
19:  }  

Write C Program to Print Reverse Number of Input Numbers

1:  #include <stdio.h>  
2:  int main()  
3:  {  
4:    int n, reverse = 0;  
5:    printf("Enter a number to reverse\n");  
6:    scanf("%d", &n);  
7:    while (n != 0)  
8:    {  
9:     reverse = reverse * 10;  
10:     reverse = reverse + n%10;  
11:     n    = n/10;  
12:    }  
13:    printf("Reverse of entered number is = %d\n", reverse);  
14:    return 0;  
15:  }  

Friday 10 July 2015

Write C Program to Swap two numbers

1:  #include <stdio.h>  
2:  int main()  
3:  {  
4:    int x, y, temp;  
5:    printf("Enter the value of x and y\n");  
6:    scanf("%d%d", &x, &y);  
7:    printf("Before Swapping\nx = %d\ny = %d\n",x,y);  
8:    temp = x;  
9:    x  = y;  
10:    y  = temp;  
11:    printf("After Swapping\nx = %d\ny = %d\n",x,y);  
12:    return 0;  
13:  }  

Write C program to Decimal to Binary Conversion

1:  #include <stdio.h>  
2:  int main()  
3:  {  
4:   int n, c, k;  
5:   printf("Enter an integer in decimal number system\n");  
6:   scanf("%d", &n);  
7:   printf("%d in binary number system is:\n", n);  
8:   for (c = 31; c >= 0; c--)  
9:   {  
10:    k = n >> c;  
11:    if (k & 1)  
12:     printf("1");  
13:    else  
14:     printf("0");  
15:   }  
16:   printf("\n");  
17:   return 0;  
18:  }  

Monday 6 July 2015

Write C Program To Find LCM and HCF

1:  #include <stdio.h>  
2:  int main() {  
3:   int a, b, x, y, t, gcd, lcm;  
4:   printf("Enter two integers\n");  
5:   scanf("%d%d", &x, &y);  
6:   a = x;  
7:   b = y;  
8:   while (b != 0) {  
9:    t = b;  
10:    b = a % b;  
11:    a = t;  
12:   }  
13:   gcd = a;  
14:   lcm = (x*y)/gcd;  
15:   printf("Greatest common divisor of %d and %d = %d\n", x, y, gcd);  
16:   printf("Least common multiple of %d and %d = %d\n", x, y, lcm);  
17:   return 0;  
18:  }  

Write C Program To Find Factorial of Inputed Number

1:  #include <stdio.h>  
2:  int main()  
3:  {  
4:   int c, n, fact = 1;  
5:   printf("Enter a number to calculate it's factorial\n");  
6:   scanf("%d", &n);  
7:   for (c = 1; c <= n; c++)  
8:    fact = fact * c;  
9:   printf("Factorial of %d = %d\n", n, fact);  
10:   return 0;  
11:  }  

Write C Program To Perform Inputed Degits Summation

Write C Program To Perform Inputed Degits Summation
1:  int main()  
2:  {  
3:    int n, t, sum = 0, remainder;  
4:    printf("Enter an integer");  
5:    scanf("%d", &amp;n);  
6:    t = n;  
7:    while (t != 0)  
8:    {  
9:     remainder = t % 10;  
10:     sum    = sum + remainder;  
11:     t     = t / 10;  
12:    }  
13:    printf("Sum of digits of %d = %d", n, sum);  
14:    return 0;  
15:  }  

Write C Program To Check inputed Number is Leap Year Or Not

1:  int main()  
2:  {  
3:   int year;  
4:   printf("Enter a year to check if it is a leap year<span style="font-weight: bold;">\n</span>");  
5:   if ( year%400 == 0)  
6:    printf("%d is a leap year.", year);  
7:   else if ( year%100 == 0)  
8:    printf("%d is not a leap year.", year);  
9:   else if ( year%4 == 0 )  
10:    printf("%d is a leap year", year);  
11:   else  
12:    printf("%d is not a leap year.", year);   
13:   return 0;  
14:  }  

Write C Program To Check Inputed Character is Vowel Or Not

Write C Program To Check Inputed Character is Vowel Or Not
1:  int main()  
2:  {  
3:   char ch;  
4:   printf("Enter a character");  
5:   scanf("%c", &ch);  
6:   if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')  
7:    printf("%c is a vowel", ch);  
8:   else  
9:    printf("%c is not a vowel.", ch);  
10:   return 0;  
11:  }  

Write C Program To Perform Airthmetic Operation Addition , Multiplication, Subtraction,Division of two Numbers

Write C Program To Perform Airthmetic Operation Addition , Multiplication, Subtraction,Division of two Numbers
1:  #include <stdio.h>  
2:  int main()  
3:  {  
4:    int first, second, add, subtract, multiply;  
5:    float divide;  
6:    printf("Enter two integers\n");  
7:    scanf("%d%d", &first, &second);  
8:    add = first + second;  
9:    subtract = first - second;  
10:    multiply = first * second;  
11:    divide = first / (float)second;  //typecasting  
12:    printf("Sum = %d",add);  
13:    printf("Difference = %d",subtract);  
14:    printf("Multiplication = %d",multiply);  
15:    printf("Division = %.2f",divide);  
16:    return 0;  
17:  }  

Write C Program To Check Odd And Even Numbers

Write C Program To Check Odd And Even Numbers
1:  #include <stdio.h>  
2:  int main()  
3:  {  
4:    int n;  
5:    printf("Enter an integer\n");  
6:    scanf("%d", &n);  
7:    if (n%2 == 0)  
8:     printf("Even");  
9:    else  
10:     printf("Odd");  
11:    return 0;  
12:  }  

Write C Program Addition of Two Numbers

Write C Program Addition of Two Numbers
1:  int main()  
2:  {  
3:    int a, b, c;  
4:  
5:    printf("Enter two numbers to add");  
6:    scanf("%d%d",&a,&b);  
7:  
8:    c = a + b;  
9:   
10:    printf("Sum of entered numbers = %d",c);  
11:  
12:    return 0;  
13:  }  

Write C Program Print Integer

Write C Program Print Integer
1:  int main()  
2:  {  
3:   int a;  
4:    
5:   printf("Enter an integer");  
6:   scanf("%d", &a);  
7:   printf("Integer that you have entered is %d", a);  
8:    
9:   return 0;  
10:  }  
11:    

Write C Program to Print Hello World Example

Write C Program to Print Hello World Example
1:  //C hello world example  
2:  #include <stdio.h>  
3:  int main()  
4:  {  
5:   printf("Hello world\n");  
6:   return 0;  
7:  }