-->

Facebook

Jasper Roberts - Blog
Showing posts with label CPU_2110003 Programs. Show all posts
Showing posts with label CPU_2110003 Programs. Show all posts

Friday, April 3, 2015

W.A.P to read array of integers and print it in reverse order.

Practical Set-4
W.A.P to reaarray of integers and print it in reverse order.

#include<stdio.h>
#include<conio.h>

void main()
{
   int n, i, j, a[100], b[100];

   printf("Enter the number of elements in array:\n");
   scanf("%d", &n);

   printf("Enter the array elements:\n");

   for (i = 0; i < n ; i++)
      scanf("%d", &a[i]);

   for (i = n - 1, j = 0; i >= 0; i--, j++)
      b[j] = a[i];

   for (i = 0; i < n; i++)
      a[i] = b[i];

   printf("Reverse array is:\n");

   for (i = 0; i < n; i++)
      printf("%d\n", a[i]);

   getch();
}

OUTPUT:
Enter the number of elements in array: 3
Enter the array elements:
3
1
2
Reverse array is:
2
1
3

Wednesday, October 15, 2014

Write a c program to print first n Fibonacci numbers.


#include<stdio.h>
#include<conio.h>

void main()
{
int num1=0, num2=1, num3, n, i;
clrscr();

Tuesday, October 14, 2014

Write a c program to draw the following pattern-5.


/*
     12345
      2345
       345
        45
         5
*/


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();

for(i=1;i<=5;i++)
{

Monday, October 13, 2014

Write a C Program to draw following patter-4.

/* 
     1
     10
     101
     1010
     10101

*/


#include<conio.h>
#include<stdio.h>

void main()
{
     int i,j;
     clrscr();
    
     for(i=1;i<=5;i++)
     {
          for(j=1;j<=5;j++);
          {

Write a C Program to draw following patter-3.

/* 
     1
     22
     333
     4444
     55555

*/


#include<conio.h>
#include<stdio.h>

void main()
{
     int i,j;
     clrscr();
    
     for(i=1;i<=5;i++)
     {
          for(j=1;j<=5;j++);
          {
              printf(“%d”,i);

Write a C Program to draw following patter-2.

/*
     1
     12
     123
     1234
     12345

*/


#include<conio.h>
#include<stdio.h>

void main()
{
     int i,j;
     clrscr();
    
     for(i=1;i<=5;i++)
     {
          for(j=1;j<=5;j++);

Write a C Program to draw following patter -1

/*
     *
     **
     ***
     ****
     *****

*/


#include<conio.h>
#include<stdio.h>

void main()
{
     int i,j;
     clrscr();
    
     for(i=1;i<=5;i++)
     {
          for(j=1;j<=5;j++);
          {

Thursday, September 18, 2014

PRACTICAL-SET—1

Write a C Program to select & print the largest of the three nos. using Nested-If-Else statement.

#include<stdio.h>
#include<conio.h>

void main()
{
      int a,b,c;
      clrscr();

      printf("Enter the values of a: ");
      scanf("%d",&a);

      printf("Enter the values of b: ");
      scanf("%d",&b);

      printf("Enter the values of c: ");
      scanf("%d",&c);



     if(a>b)
    {
             if(a>c)
             {
                       printf(" a is largest number.");
             }
             else
            {
                        printf(" c is largest number.");
            }
     }
    
    else
    {
            if(b>c)
           {
                       printf(" b is largest number.");
           }
           else
          {
                      printf(" c is largest number.");
          }
    }

getch();

}



OUTPUT:

largest.c

Write a C Program to convert years into months and days.

#include<stdio.h>
#include<conio.h>

void main()
{
int years,months,days;
clrscr();

printf("\n Enter the number of years: ");
scanf("%d",&years);

months = 12 * years;

days = 365 * years;

printf("\n Total Months are : %d",months);
printf("\n Total Days are : %d",days);

getch();

}

OUTPUT:

c program to convert years into months and days
years.c

Write a C Program that reads two nos. from key board and gives their addition, subtraction, multiplication, division and modulo.

#include<stdio.h>
#include<conio.h>

void main()
{
int value1, value2, addition, subtraction, multiply;
float divide,mod;

clrscr();

printf("\n Enter the value1: ");
scanf("%d",&value1);

printf("\n Enter the value2: ");
scanf("%d",&value2);

addition = value1 + value2;
subtraction = value1 - value2;
multiply = value1 * value2;
divide = value1 / (float)value2;
mod = value1 % value2;

printf("\n Addition       = %d + %d = %d",value1,value2,addition);
printf("\n Subtraction    = %d - %d = %d",value1,value2,subtraction);
printf("\n Multiplication = %d * %d = %d",value1,value2,multiply);
printf("\n Division       = %d / %d = %.0f",value1,value2,divide);
printf("\n Modulo         = %d MOD %d = %.0f",value1,value2,mod);
 
    getch();
}

OUTPUT:

c program to add, sub, multi, div of two numbers
calculator.c


RELATED PROGRAMS

a. Writea program to print ―HELLO FRIENDS!!
c. Writea program to convert years intomonths and days. 
d. Write a prograto solve Quadratic Equation.