Pages

Friday, 8 February 2019

Program to find smallest number in an array of One Dimensional Array

Program to find smallest number in an array of one dimensional array
#include <stdio.h>
#define size 22
void main()
{
  int a[size],i,n,min;
  printf("\n Enter the size of an array : ");
  scanf("%d",&n);
  for(i = 0; i < n; i++)
   {
    scanf("%d",&a[i]);
   }
  printf("\n Array elements are  : ");
  for(i = 0; i < n; i++)
   {
    printf("\n Address : %p  --> Array  : a[%d]  --> Data : %d ",&a[i],i,a[i]);
   }
   min=a[0];
   for(i = 0; i < n; i++)
   {
    if(a[i]<min)
       min=a[i];
    }
    printf("\n smallest number in an array is %d",min);
}

output:

Program to find largest number in an array of One Dimensional Array

Program to find largest number in an array of one dimensional array

#include <stdio.h>
#define size 22
void main()
{
  int a[size],i,n,max;
  printf("\n Enter the size of an array : ");
  scanf("%d",&n);
  for(i = 0; i < n; i++)
   {
    scanf("%d",&a[i]);
   }
  printf("\n Array elements are  : ");
  for(i = 0; i < n; i++)
   {
    printf("\n Address : %p  --> Array  : a[%d]  --> Data : %d ",&a[i],i,a[i]);
   }
   max=a[0];
   for(i = 0; i < n; i++)
   {
    if(a[i]>max)
       max=a[i];
    }
    printf("\n largest number in an array is %d",max);
}

output:

Program to illustrate One Dimensional Array with address

Program to illustrate One Dimensional Array with address array and data
#include <stdio.h>
#define max 22
int main()
{
  int a[max],i,n;
  printf("\n Enter the size of an array : ");
  scanf("%d",&n);
  for(i = 0; i < n; i++)
   {
    scanf("%d",&a[i]);
   }
  printf("\n Array elements are  : ");
  for(i = 0; i < n; i++)
   {
    printf("\n Address : %p  --> Array  : a[%d]  --> Data : %d ",&a[i],i,a[i]);
   }
}

Output:

Program to illustrate One Dimensional Array

one dimensional array:
              An array which has only one subscript is known as one dimensional array i.e) int a[5].

Syntax
data_type varname[size];

Declaration of an array program :
              In C programming, programmers can also initialize the array variable without mentioning the size of an array. The compiler will automatically  deduct the size of an array.

declaration-1
int student[5] = {89, 76, 98, 91, 84};

declaration-2
int student[] = {89, 76, 98, 91, 84};


Program:
#include <stdio.h>
int main()
{
int s[5] = {89, 76, 98, 91, 84}, i;
printf("\n---Students marks details--- ");
for(i = 0; i < 5; i++)
{
printf("\ns%d = %d ", i + 1, s[i]);
}
return 0;
}

output;

Monday, 4 February 2019

PROGRAM TO ILLUSTRATE FORWARD AND BACKWARD JUMP

PROGRAM TO ILLUSTRATE FORWARD AND BACKWARD JUMP

// prg to illustrate forward jump
#include<stdio.h>
void main()
{
 printf("\n start of program :");
 printf("\n Forward jump program :");
 goto label;
 printf("\n I am inside label");
 label:
 printf("\n end of the program");
}   

output:


// prg to illustrate backward jump
#include<stdio.h>
void main()
{
 printf("\n start of program ");
 label:
 printf("\n I am inside the label");
 goto label;
 printf("\n end of the program");
}    


output:



Sunday, 3 February 2019

PROGRAM TO ILLUSTRATE CONTINUE AND BREAK STATEMENTS

CASE CONTROL STRUCTURES:

1. continue statement program:

// prg to illustrate continue statement
#include<stdio.h>
void main()
{
 int i=1,n,s;
 printf("enter n value:");
 scanf("%d",&n);
 printf("enter skip value:");
 scanf("%d",&s);
 for( i=1; i <= n ; i++)
  {
   if (i == s)
   {
   printf("\nSkipping %d from display using continue statement \n",i);
   continue;
   }
   printf("%d\n",i);
 }
}  







output:


2. break statement program:

// prg to illustrate break statement
#include<stdio.h>
void main()
{
 int i=1,n,s;
 printf("enter n value:");
 scanf("%d",&n);
 printf("enter skip value:");
 scanf("%d",&s);
 for( i=1; i <= n ; i++)
  {
   if (i == s)
   {
   printf("\nSkipping %d from display using continue statement \n",i);
   break;
   }
   printf("%d\n",i);
 }
}  
output:

Fibonacci series

// prg to illustrate fibonacci series of a given number
#include<stdio.h>
void main()
{
 int n,i,past=0,present=1,future;
 printf("enter any number:");
 scanf("%d",&n);
 printf("\n %d \n%d",past,present);
 future=past+present;
 printf("\n %d",future);
 for(i=0;i<n-3;i++)
  {
   past=present;
   present=future;
   future=past+present;
   printf("\n %d",future);
  }
}

 output

Programs in turboc3 : Files

File Handling in C File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our...