Scroll To Top
News Trending

Latest Post

Entertainment

Business

Technology

Related Posts Plugin for WordPress, Blogger...
Related Posts Plugin for WordPress, Blogger...
Related Posts Plugin for WordPress, Blogger...

Recent Posts

Program of first come first serve(FCFS) in Operating Sysytem

/ No Comments
#include<stdio.h>
#include<conio.h>

void main()
{
        int a,n,i,j,pa[10],pb[10],pt[10],pc[10],pw[10],ptat[10],pa2[10];
        printf("Enter the no. of process");
        scanf("%d",&n);
        for(a=0;a<n;a++)
        {
                printf("Enter the arrival time and the cpu brust time of process %d\n",a+1);
                scanf("%d%d",&pa[a],&pb[a]);
                pc[a]=pb[a];
                pa2[a]=pa[a];
        }
        for(i=0;i<n;i++)
        {
                for(j=i;j<n;j++)
                {
                        if(pa[i]>pa[j])
                        {
                                a=pa[i];
                                pa[i]=pa[j];
                                pa[j]=a;
                                a=pb[i];
                                pb[i]=pb[j];
                                pb[j]=a;
                        }
                }
        }
        for(a=0;a<n;a++)
        {
                printf("\n%d\t%d",pa[a],pb[a]);
        }
        printf("\n");
        pt[0]=0;
        for(a=1;a<n;a++)
        {
                pt[a]=pt[a-1]+pb[a-1];

        }
        for(a=0;a<n;a++)
        {
                pw[a]=pt[a]-pa[a];
                ptat[a]=pw[a]+pb[a];
                //printf("\nWaiting Time %d\t %d",a+1,pw[a]);

        }
        for(i=0;i<n;i++)
        {
                for(j=0;j<n;j++)
                {
                        if(pb[j]==pc[i] && pa[j]==pa2[i])
                                printf("\nTAT%d \t %d",i+1,ptat[j]);
                }
        }
        printf("\n");
        i=0;
        for(a=0;a<n;a++)
        {
                i=i+ptat[a];
        }
        printf("\nTotal TAT = %d\nAverage TAT = %d",i,i/n);

        getch();
}

Program to check leap year.

/ No Comments


Q. Write a program to check leap year.


#include <stdio.h>

int main()
{
  int year;

  printf("Enter a year to check if it is a leap year\n");
  scanf("%d", &year);

  if ( year%400 == 0)
    printf("%d is a leap year.\n", year);
  else if ( year%100 == 0)
    printf("%d is not a leap year.\n", year);
  else if ( year%4 == 0 )
    printf("%d is a leap year.\n", year);
  else
    printf("%d is not a leap year.\n", year);

  return 0;
}

C program to perform addition, subtraction, multiplication and division.

/ No Comments
C program to perform basic arithmetic operations which are addition, subtraction, multiplication and division of two numbers. Numbers are assumed to be integers and will be entered by the user.


#include <stdio.h>
 
int main()
{
   int first, second, add, subtract, multiply;
   float divide;
 
   printf("Enter two integers\n");
   scanf("%d%d", &first, &second);
 
   add        = first + second;
   subtract = first - second;
   multiply = first * second;
   divide     = first / (float)second;   //typecasting
 
   printf("Sum = %d\n",add);
   printf("Difference = %d\n",subtract);
   printf("Multiplication = %d\n",multiply);
   printf("Division = %.2f\n",divide);
 
   return 0;
}


In c language when we divide two integers we get integer result for example 5/2 evaluates to 2. As a general rule integer/integer = integer and float/integer = float or integer/float = float. So we convert denominator to float in our program, you may also write float in numerator. This explicit conversion is known as typecasting.

C Program to check whether the No. is Odd or Even.

/ No Comments


Hello friends in this program we will determine whether the no is even or odd using C code. As you have study in mathematics that in decimal number system even numbers are divisible by 2 while odd are not so we may use modulus operator(%) which returns remainder, For example 4%3 gives 1 ( remainder when four is divided by three). Even numbers are of the form 2*p and odd are of the form (2*p+1) where p is is an integer.


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

void main()
{
int n;
clrscr();
printf("Enter a no. \n");
scanf("%d",&n);
if(n%2==0)
printf("No. is even.\n");
else
printf("No. is odd\n");
getch();
}

C program to add two int numbers.

/ No Comments


In this program we can add two integer values. Given by the user.

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

void main()
{
int a,b,c;
clrscr();
printf("Enter two noumbers : \n");
scanf("%d %d",&a,&b);
c=a+b;
printf("addition is %d \n",c);
getch();
}

C program to Input and print a "String"

/ No Comments
In this program you can input a string and print it on the screen.


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

void main()
{
char str[100] ={'p','c','w','o','r','l','d','l','i','f','e'};
clrscr();
printf("\n%s\n",str);
getch();
printf("Enter a string\n");
scanf("%s",str);
printf("\nEntered string is\n%s \n",str);
getch();
}

C program to take input and print the value of a Int And Float.

/ No Comments

In this program you will learn about to take input to the variables and print their values. The values are depends on the input .

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

void main()
{
int a;
float c;
clrscr();                                            //to clear the screen.
printf("Enter the value of int\n");   //\n is used for new line
scanf("%d",&a);
printf("\na = %d",a);                      //& is used to store the value at the location of a, %d for int.
printf("\n\nEnter the value of float\n");
scanf("%f",&c);
printf("\nc = %f",c);
getch();
}