In FCFS the processes are in served by the order they arrive and each process will not start until the served process is finished, so if any of the processes got stuck in an infinite CPU loop the whole system will stop and hang.
Write a c program for profit and loss percentage?
#include<stdio.h>
#include<conio.h>
void main()
{
float cp, sp, p, l;
clrscr();
printf("\n Enter cost price and selling price:");
scanf("%f%f",&cp, &sp);
p=sp-cp;
l=cp-sp;
if(p>0)
{printf("\n The seller has made a profit of Rs.%f",p);
}
else if(l>0)
{printf("\n The seller is in loss by Rs.%f",l);
}
else
{printf("\n There is no loss or no profit");
}
}
i m sure this will help u.....
shalini
What are the disadvantages of nested if in C?
Nothing, but be careful with the dangling else's:
if (cond1) if (cond2) stmt1; else stmt2;
means:
if (cond1) {
if (cond2) stmt1; else stmt2;
}
not this:
if (cond1) {
if (cond2) stmt1;
} else stmt2;
Can two expressions or conditioned be used in while statement?
Yes, it works similar to an IF statement using logical operators.
For instance this would work, but if either of the boolean values were false at the end of the loop it would leave the loop.
bool a = true;
bool b = true;
while (a && b)
{
//run code
}
or: while (exp1 exp2) dosomething
#include<stdio.h>
#include<conio.h>
void main()
{
int num,num_save;
int ar[5],i=0,res_e=0,res_o=0;
printf("\nEnter the number : ");
scanf("%d",&num);
num_save=num;
while(num_save>0)
{
ar[i]=num_save%10;
num_save/=10;
i++;
}
i--;
while(i>=0)
{
if(ar[i]%2==0)
res_e=res_e+ar[i];
else
res_o=res_o+ar[i];
}
printf("\nNumber is %d\n",num);
printf("\nSum of even digits is %d",sum_e);
printf("\nSum of odd digits is %d",sum_o);
getch();
}
How do you calculate space complexity?
Calculate the amount of additional memory used by the algorithm relative to the number of its inputs. Typically the number of inputs is defined by a container object or data sequence of some type, such as an array. If the amount of memory consumed remains the same regardless of the number of inputs, then the space complexity is constant, denoted O(1) in Big-Omega notation (Big-O). If the amount of memory consumed increases linearly as n increases, then the space complexity is O(n).
For example, the algorithm that sums a data sequence has O(1) space complexity because the number of inputs does not affect the amount of additional memory consumed by the accumulator. However, the algorithm which copies a data sequence of n elements has a space complexity of O(n) because the algorithm must allocate n elements to store the copy.
Other commonly used complexities include O(n*n) to denote quadratic complexity and O(log n) to denote (binary) logarithmic complexity. Combinations of the two are also permitted, such as O(n log n).
Write a programme for substraction of two numbers in c language?
substracion of any two number program in c
How is c language different from fuzzy logic?
fuzzy logic is a logic which we have to implement in c language
Why use length function to find length of primitive data type array object?
There is no length function in C. You may have thought of sizeof or strlen. Perhaps.
22 matrix with 33 matrix multiplication?
It is not possible. The number of columns in the first matrix must be the same as the number of rows in the second.
That is, matrices, X (kxl) and Y (mxn) can only be multiplied [in that order] if l = m.
How do you pass command line arguments using turbo in c compiler?
In the Options menu the Arguments command.
How do you write a C program to find the GCD of two given integers using non recursive functions?
Use the following function:
int gcd (int a, int b) {
while (b != 0) {
a %= b;
a ^= b ^= a ^= b;
}
return a;
}
Note that a ^= b ^= a ^= b is an efficient method of swapping two values.
How do you get a random number from a group of numbers in C?
Random numbers cannot be generated programatically. For pseudo-random numbers use function 'rand'.
Explain how do you increase the cohesiveness of a group structure?
Some good ways to increase the cohesiveness of a group is to use team building exercises. You can start your meeting with these to improve each group session.
Assembly language is a low level language where each statement (mostly) corresponds with one machine instruction. Higher level languages, such as C and FORTRAN, generate multiple machine instructions for each statement.
What is the difference between passing an array and passing single value data to a function?
Passing a single value to a function is often just a simple integer. But passing an array, character string or other data structure is typically "pass by reference", or in other words, the calling statement will 'point to' the place in memory where the data structure resides.
When a function is called using a pointer to a data structure, both the calling environment and the called function are referencing the same data; any changes made to the data in the structure by the function will have changed the data that the original calling environment sees.
However, when a value is passed to a function, the function creates it's own copy of the value, and can change it in any way without changing the original value.
What is the practical application for a binary converter?
The reason that binary trees are used more often than n-ary trees for searching is that with every contract with an n-ary tree you can eliminate most of it.
An object is the most primitive element of a program written in the OOP language.A method of an object defines the set of operations that the object will execute when a message corresponding to the method is received by the object.The binding of a message to an method is dynamic. The entire collection of methods of an object is called the "message interface" or " message protocol".