How do you print gantt chart for round robin in c?
#include<stdio.h>
struct RRS
{
char p[2];
int btime;
}a[5];
void main()
{
struct RRS a[5];
int i,j,n,k=0,totalbtime=0;
printf("\nEnter the no of process");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n enter the process name and burst time");
scanf("%s %d", a[i].p, &a[i].btime);
}
for(i=0;i<n;i++)
{
printf("\n process: %s \t btime : %d",a[i].p,a[i].btime);
totalbtime=totalbtime+a[i].btime;
}
while(k<totalbtime)
{
for(i=0;i<n;i++)
{
for(j=0;j<2;j++)
{
if(a[i].btime!=0)
{
printf("%s",a[i].p);
a[i].btime--;
k++;
}
}
}
}
}
output:
enter the no of process:3
enter the process name and btime:p1 4
enter the process name and btime:p2 3
enter the process name and btime:p3 1
processname btime
p1 4
p2 3
p3 1
p1p1p2p2p3p1p1p2
What does non-linear data structure mean?
When we speak of linear and no-linear data structures, we are referring to the links between one element and the next. These links determine how we traverse the structure such that we "visit" every element in the structure. When every element has only one possible link to the next in sequence, then the structure is said to be linear. If any element has two or more possible links, it is said to be non-linear.
Arrays, lists, stack and queues are examples of linear structures. Trees, networks and graphs are examples of non-linear structures.
A binary tree is the simplest example of a non-linear structure because every element has, at most, two possible links, a left link and a right link. If we follow the left link, then at some point we must return to that same element in order to follow its right link. This means we must backtrack. Any structure that requires us to backtrack during a traversal is therefore non-linear.
Linear traversal is more efficient than non-linear traversal because there is no need to backtrack to traverse a linear data structure.
What is the Function of a computer in a library?
TO STORE DETAILS ABOUT THE BOKS LIKE BOOKNAME,COST,AUTHOR,PUBLISHER etc
scanf() is an input function which reads input from the standard input devices such as keyboard.
Syntax:
scanf("Control Character",address_list);
where control character is a sequence of one or more character such as %d,%f,%lf,%lld. Address list specifies the variables, pointers etc.
e.g. scanf("%d",&num);
How do you animate Tom and Jerry in C programming?
Generally you wouldn't. Tom and Jerry are owned by Time Warner and only they have the legal right to animate the characters or allow others to do so on their behalf. Even so, they wouldn't use C programming to do so, they'd use animation software, as would anyone producing animations of any kind. The software may well be written in C/C++, but this is not the same as animating in C/C++. At the core of all animation software is a 2D or 3D engine that provides the basics of animation; multi-level 2D backgrounds and foregrounds or a 3D virtual world -- the "stage" within which to animate the "actors", which are modelled separately and composited within the "stage", along with "props". The output of all animation software is a movie file (AVI, MPEG, etc) in standard or high definition, or a series of still images (BMP, etc) that can be replayed as a movie.
The expression --x is functionally equivalent to x = x - 1.
Program for inserting a new node in between two list in c?
To insert a new node between two lists, append the new node to the first list, then insert the head node of the second list after the new node.
What are the disadvantages of high level languages?
Though it is much easier to code in a high level language, oftentimes access to more low-level functionalities are lost. For instance, the ability to communicate directly with the compiler and alter code before it gets transferred into machine code is lost. An example of this is the ability to optimize code in C, whereas the Java Compiler is a different deal altogether. Other abilities may include memory management, but mainly deal with behind-the-scenes architecture-related or runtime things.
Can an identifier be used as a keyword?
As is used to import Module name as short short cut...
EX: import math as m
........Husnu
Write a program to find the geometric progression in c?
#include(stdio.h) // place this '<' & '>' instead of '(' & ')' before stdio.h
#include(conio.h)
#include(math.h)
int main( )
{
int x, n, sum,power;
clrscr( );
printf("Enter the values of x and n:");
scanf("%d%d", &x, &n);
if(n<0 style="font-weight: bold; color: rgb(255, 0, 0);">
{
printf("\nSorry, the formula does not make sense for negative exponents & values");
printf("Enter the values of x and n:");
scanf("%d%d", &x, &n);
sum=1;
for(power=1; power <=n; power++) {
sum=sum+ pow(x,power); }
printf("X value is: %d \nN value is: %d", x, n);
printf("\nSum of the given geometric progression: %d", sum);
}
else
{
sum=1;
for(power=1; power <=n; power++) {
sum=sum+ pow(x,power); }
printf("X value is: %d \nN value is: %d", x, n);
printf("\nSum of the given geometric progression: %d", sum);
}
getch( );
return 0;
}
In c plus plus Programming can you replace STDio header with using name space STD?
No. You can't use namespace std even if you include stdio.h. At the very least you must include stddef.h before you can use namespace std.
Is it possible to use the bubble sort algorithm to sort strings?
Bubble sort will be able to sort the items lexicographically, if you first assign the strings a relative value. The way strcmp in the C library does this is by returning the difference of the first different characters between the strings. For instance, if you call strcmp("Hello", "Highway"), strcmp will return 'e'-'i'. The ascii value of e on a unix system is 101 and the ascii value of i is 105, so it is returning the value 101-105 = -4 which will tell you that "Hello" is lexicographically smaller than "Highway". Doing this, you should be able to use any algorithm you want to sort the strings.
How you generate power set using c program?
#include <iostream>
void printSet(int array[],int size){
int i;
for (i=1;i<=size;i++)
std::cout << array[i] << " ";
std::cout << std::endl;
return;
}
void printPowerset (int n){
int stack[10],k;
stack[0]=0; /* 0 is not considered as part of the set */
k = 0;
while(1){
if (stack[k]<n){
stack[k+1] = stack[k] + 1;
k++;
}
else{
stack[k-1]++;
k--;
}
if (k==0)
break;
printSet(stack,k);
}
return;
}
int main(){
printPowerset(4);
return 0;
}
It's the process of stepping through each node of a binary tree so that you reach each one at least once.
Binary tree traversal is special in that the output of the tree is sorted.
If you're looking for how it is done, I would highly recommend reading up on binary trees. It is easy to describe in pictures or code. I recommend against trying to get a description in text, it would only be confusing.
How do you write a C program to check a Given Number Whether is it Palindrome or Not?
#include void main() { long int n; printf("ENTER A NUMBER: "); scanf("%ld",&n); int n1,mod; n1=n; int rev=0; while(n>0) { mod = n%10; rev = rev * 10 + mod; n = n / 10; } if (n1 == rev) printf("ENTERED NUMBER IS A PALINDROME\n"); else printf("ENTERED NUMBER NOT A PALINDROME\n"); }
How do you write a program to check the mistakes in paragraph?
This is no mean feat; actually no spell-checker / grammar-checker does a perfect job. Something simple you could do is just to check whether each word is in a dictionary. The data structures you use will depend on the programming language chosen, but having your dictionary in an array would definitely be slow - you may want to use something like a hashtable or a binary tree instead. However, an array can work for a proof of concept.
If you write your program this way, something like an "Ode to the Spelling Checker" should pass without errors - although it is full of errors. The "Ode to the Spelling Checker" uses words that are in the dictionary - but the wrong word in each case, for example "eye" instead if "I", and "tolled" instead of "told". I paste a copy of the Ode here, for your easy reference - you'll have to read it out loud to make sense out of it!
Eye halve a spelling chequer
It came with my pea sea
It plainly marques four my revue
Miss steaks eye kin knot sea.
Eye strike a quay and type a word
And weight four it two say
Weather eye am wrong oar write
It shows me strait a weigh.
As soon as a mist ache is maid
It nose bee fore two long
And eye can put the error rite
It's rare lea ever wrong.
Eye have run this poem threw it
I am shore your pleased two no
It's letter perfect awl the weigh
My chequer tolled me sew.
Its like testing a car without running it. Testing the code without actually running it.
Code reviews by peers, checklist are popular techniques.
The Dipylon Amphora painted with primitive human figures is typical of what technique in?
Red-figured
The following example sets up a two-dimensional array, initialises it with some pseudo-random data, and then prints the table and the averages.
#include<iostream>
#include<time.h>
int main()
{
const int max_students = 7;
const int max_student_grades = 5;
const int max_grades = 6;
const char grade[max_grades]={'A','B','C','D','E','F'};
srand((unsigned) time(NULL));
// Initialise the array with pseudo-random grades:
int table[max_students][max_student_grades];
for(int student=0; student<max_students; ++student)
{
for(int student_grade=0; student_grade<max_student_grades; ++student_grade)
{
table[student][student_grade] = rand()%max_grades;
}
}
// Print the table and average the results.
int overall=0;
for(int student=0; student<max_students; ++student)
{
int average=0;
std::cout<<"Student #"<<student+1;
for(int student_grade=0; student_grade<max_student_grades; ++student_grade)
{
std::cout<<" Grade #"<<student_grade+1<<": "<<grade[table[student][student_grade]]<<", ";
average+=table[student][student_grade];
}
std::cout<<" Average: "<<grade[average/max_grades]<<std::endl;
overall+=average;
}
std::cout<<"Overall average: "<<grade[overall/max_grades/max_students]<<std::endl;
return(0);
}
Example output:
Student #1 Grade #1: A, Grade #2: E, Grade #3: D, Grade #4: E, Grade #5: F, Average: C
Student #2 Grade #1: E, Grade #2: D, Grade #3: E, Grade #4: E, Grade #5: E, Average: D
Student #3 Grade #1: D, Grade #2: A, Grade #3: D, Grade #4: B, Grade #5: A, Average: B
Student #4 Grade #1: C, Grade #2: B, Grade #3: A, Grade #4: A, Grade #5: B, Average: A
Student #5 Grade #1: E, Grade #2: D, Grade #3: C, Grade #4: F, Grade #5: E, Average: D
Student #6 Grade #1: C, Grade #2: D, Grade #3: A, Grade #4: F, Grade #5: A, Average: B
Student #7 Grade #1: B, Grade #2: D, Grade #3: F, Grade #4: B, Grade #5: C, Average: C
Overall average: C
C program for storage representation of 2-D array?
Wright a 'C' program for storage representation of 2-D array.
How Exampes of Accounting Rate of Return - ARR?
Year Net Income Net Cash Flow
0 0 (98500)
1 7500 24750
2 95000 31000
3 14750 34000
4 21250 40250
5 24950 44500
calculate accounting rate of return?
Abstract data types (ADTs) are defined by base class designers. An ADT differs from an ordinary base class in that it has a pure-virtual interface. As with all base classes, the protected interface is intended for use by class implementers while the public interface is intended for all programmers (consumers).
All member data should be declared private. Even if there is no invariant associated with the data, declaring it private and providing a public interface ensures that any changes to the class representation will not affect consumers. Member data is an implementation detail that should be of no concern to either the class implementer or the consumer. Protected member data should always be treated with suspicion as this essentially exposes an implementation detail to implementers that could undermine encapsulation. Abstract data types in particular should have few data members, preferably none at all.
Class implementers are only concerned with the protected and public interfaces of their bass classes. Protected interfaces should be fully-documented as the implementer needs to know which methods need to be overridden and for what reason. A common convention is to place the protected interface default implementations in a separate translation unit, typically with a "_impl" suffix. This helps implementers examine the implementation details and thus eliminate redundant/duplicate code from their overrides. Nevertheless, a well-defined interface should be self-documenting and intuitive; the class header file should provide all the documentation necessary for an implementer or consumer to use the class without the need to examine the implementation details.
piping critical , non critical critical piping : where temperature ,pressure are high and sizes of pipe are big and piping connected to critical equipment( such pump,turbine compressor etc) non critical : other than criti