C program for newton's backward interpolation?
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<math.h>
void main()
{
int n;
int i,j;
float ax[10];
float ay[10];
float x;
float y=0;
float h;
float p;
float diff[20][20];
float y1,y2,y3,y4;
clrscr();
printf("\t\t!! NEWTON GRAGORY FORWARD INTERPOLATION FORMULA!!\n");
printf("\t\t By KRISHAN \t\t\n");
printf("\t\t enter the no of terms ->");
scanf("%d",&n);
printf("\n\t\t enter the value in form of x->");
for(i=0;i<n;i++)
{
printf("\n\t\t enter the value of x%d->",i+1);
scanf("%f",&ax[i]);
}
printf("\n\t\tenter the value in the form of y->");
for(i=0;i<n;i++)
{
printf("\n\t\tenter the value of y %d->",i+1);
scanf("%f",&ay[i]);
}
printf("\n\t\tenter the value of x for");
printf("\n\t\t which u want the value of y->");
scanf("%f",&x);
h=ax[1]-ax[0];
for(i=0;i<n-1;i++)
diff[i][1]=ay[i+1]-ay[i];
for(j=2;j<=4;j++)
for(i=0;i<n-j;i++)
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
do
{
i++;
}
while(ax[i]<x);
i--;
p=(x-ax[i])/h;
y1=p*diff[i-1][1];
y2=p*(p+1)*diff[i-1][2]/2;
y3=p*(p+1)*(p-1)*diff[i-2][3]/6;
y4=(p+2)*(p+1)*p*(p-1)*diff[i-3][4]/24;
y=ay[i]+y1+y2+y3+y4;
printf("\n\t\t when x=%6.4f,y=%6.8f",x,y);
printf("\n\n\n\t\t\t!! PRESS ENTER TO EXIT!!");
getch();
}
#include
void main()
{
int i ,j=0; /* j is used for counting the nos greater than 4 from 1 to 10*/
for(i=1;i<=10;i++)
if(i>4)
j++;
printf("\n The numbers greater than 4 , from 1 to 10 is %d",j);
}
Algorithmstep 1:start
step 2 :initialize j=0
step 3 :Initialize i=1,check whether i < 10 ,if true increment i else go to step 6
step 4: check whether i >4 If true go to step5 ,else go to step 3
step 5 :Increment j and then go to step 3
step 6:print the value of j
step 7 :Stop
Why do we avoid loops in programming?
We don't avoid loops in programming. Loops are a fundamental feature of many algorithms. If we need to iterate over a data sequence in order to perform the same set of operations upon each data element, we would use an iterative loop. If we need to repeatedly reduce a larger problem into one or more smaller instances of the same problem until the problem is small enough to be solved we'd use a recursive loop.
Write a c program to Calculate the average of five entered number from keyboard?
Sample code is as follows:
#include <stdio.h>
void main()
{
int i = 0;
int final_number = 0;
int array[] = {1,2,3,4,5};
for(i = 0; i < (sizeof(array)/sizeof(array[0])); i++)
{
final_number += array[i];
}
printf("Sum = %d and average = %d", final_number, (final_number / i));
}
Downloaded
translators
installing
programming
programmers
A c comma c plus plus program that can accept first name surname and display it?
int main()
{
std::string first, last;
std::cout << "Enter your first name: ";
std::cin >> first;
std::cout << "Enter your last name: ";
std::cin >> last;
}
Enqueue and dequeue in data structures?
The queue insert operation is known is enqueue.
A queue has two ends namely REAR & FRONT. After the data has been inserted in a queue ,the new element becomes REAR.The queue deletion operation is known as dequeue.
The data at the front of the queue is removed .
How can you define a structure with bit field members?
We can define structure bit field members with Dot operators.
EXAMPLE:
#include <stdio.h>
int main()
{
Struct bit_field
{
Int x.4; // it allocates only 4 bits to x
Char C.6; // it allocates only 6 bits to C;
};
return 0;
}
What type of triangle has all different sides?
Scalene sides are different lengthed
isosceles two of the 3 sides are the same
equilateral, the three sides are the same lenght and are all at 90degrees
There is no such thing as an insertion search. There is only insertion sort, which is a method of sorting an unsorted list. Sequential search (or linear search) is only used with unsorted lists. If the list is sorted, a logarithmic search is quicker, by starting from the middle. If the items is not here, it must be in the lower half or the upper half, thus one half of the list can be discarded. You then repeat by starting in the middle of the remaining half. Thus for a list of 15 items, you end up with a list of 7, then 3, then 1, then 0. Thus it takes 5 comparisons to determine that an item does not exist. With linear search it would take 15 comparisons to determine that an item does not exist. Thus logarithmic search is quicker, but only works with sorted lists.
How do you write a Program in java to cheak a number is automorphic number?
Source Code ::
import java.io.*;
class automorphic
{
protected static void main()throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number: ");
int a=Integer.parseInt(in.readLine()),b=a,c=0,e=a*a;
while(b>0)
{
c++;
b/=10;
}
double d=Math.pow(10,c-1);
if(a==e%d)
System.out.println("Automorphic number!!");
else
System.out.println("Not an Automorphic number!!");
}}
Why is quick sort and merge sort called stable algorithms?
Quick sort is not stable, but stable versions do exist. This comes at a cost in performance, however.
A stable sort maintains the order of equal elements. That is, equal elements remain in the same order they were input. An unstable sort may change the order. In some cases, the order of equal elements is of no consequence, but when two elements with different values have the same sort key, then order can be important.
How long did Bill Gates work on Microsoft?
I'm actually doing a report about him, and its says that he attended public school before going to Lakeside Preparatory School at age of twelve. And also its says he attended Harvard but then dropped out his junior year to work with Microsoft.
How will you Write a c program to find the kth smallest element in an array in c?
//This is for kth largest element. (So this is for n-k smallest element) //Sudipta Kundu [Wipro Technologies] #include <stdio.h> //Input: array with index range [first, last)
//Output: new index of the pivot. An element in the middle is chosen to be a pivot. Then the array's elements are
//placed in such way that all elements <= pivot are to the left and all elements >= pivot are to the right.
int positionPivot(int* array, int first, int last); //Input: array with index range [first, last) and integer K (first <= K < last)
//Output: array whose Kth element (i.e. array[K]) has the "correct" position. More precisely,
//array[first ... K - 1] <= array[K] <= array[K + 1 ... last - 1]
void positionKthElement(int* array, int first, int last, int k); int main() {
int array[] = {7,1,8,3,1,9,4,8};
int i;
for (i = 0; i < 8; i++) {
positionKthElement(array, 0, sizeof(array) / sizeof(array[0]),i);
printf("%d is at position %d\n", array[i], i);
}
return 0;
}
int positionPivot(int* array, int first, int last) {
if (first last)
return first; int tmp = (first + last) / 2;
int pivot = array[tmp];
int movingUp = first + 1;
int movingDown = last - 1;
array[tmp] = array[first];
array[first] = pivot;
while (movingUp <= movingDown) {
while (movingUp <= movingDown && array[movingUp] < pivot)
++movingUp;
while (pivot < array[movingDown])
--movingDown;
if (movingUp <= movingDown) {
tmp = array[movingUp];
array[movingUp] = array[movingDown];
array[movingDown] = tmp;
++movingUp;
--movingDown;
}
}
array[first] = array[movingDown];
array[movingDown] = pivot;
return movingDown;
} void positionKthElement(int* array, int first, int last, int k) {
int index;
while ((index = positionPivot(array, first, last)) != k) {
if (k < index)
last = index;
else
first = index + 1;
}
}
What programming language does Unix use?
Unix was created almost entirely in C. It consists of a main component (called the kernal) and a flotilla of small utilities. Most of these utilities were written in C. Unix distributions usually come with a C compiler so you can create or modify the environment yourself.
However, C is not your only choice. Modern versions of Unix still contain a C compiler, but they often have dozens of other languages available. Most versions of Linux come with a C++ compiler (which is different than C) as well as compilers and interpreters for Java, Perl, and Python. You can generally install hundreds of other languages.
The language you use depends on the type of problem you are solving. Generally you'll use C for basic low-level work, but you'll often pick a higher-level language to solve 'real-world' problems. For example, if you're doing server-side web development, you'll usually use PHP.
What are the Advantages of files in C language?
data files are permanent storage. where as normal data types are volatile, they will save the values as long as the program runs. saving a file will provide us the flexibility to recover the saved data whenever required.
What is the maximum number of nodes that you can have on a stack linked list?
You can have as many as you can fit in memory, which is dependent on size of each node, OS, amount of RAM, etc.
How can you use the link lists as queue?
If you already have a linked list implementation, you can use it as a queue by making a few changes:
* Add a queue() function to add a node to the end of the list * Add a dequeue() function to remove and return the first node
What is the difference between departmental store and kirana stores in India?
A chain store has branches at various locations. A department store is a store where different items are displayed in different areas or floors of the same store.
A department store may be part of a chain of stores.
Suhail Reshi...
Two linked list in a array is possible?
Like this:
#define MAXLIST 100
int first, next [MAXLIST];
/* let the list be: #0 ---> #2 ---> #1 */
first= 0;
next[0]= 2;
next[2]= 1;
next[1]= -1; /* means end of list */
Note: you should track which elements are unused,
in the beginning every elements are unused:
int first_unused= 0;
for (i= 0; i<MAXLIST; ++i) next[i]= i+1;
next[MAXLIST-1]= -1; /* means end of list */
What is difference between structure and class?
The struct default access type is public. A struct shouldtypically be used for grouping data.
The class default access type is private, and the default mode for inheritance is private. A class should be used for grouping data and methods that operate on that data.
In short, the convention is to use struct when the purpose is to group data, and use classes when we require data abstraction and, perhaps inheritance.
In C++ structures and classes are passed by value, unless explicitly de-referenced. In other languages classes and structures may have distinct semantics - ie. objects (instances of classes) may be passed by reference and structures may be passed by value.
Technically there are only two differences between classes and structures:
Most C++ programmers use structures exclusively for data that doesn't require strict validation while classes are used to encapsulate data and the functions that work exclusively with that data. Although classes and structures can largely achieve the same goals, the lack of encapsulation and data-hiding in a structure make it far less robust than a well-designed class would be, with little or no difference in terms of memory consumption. Encapsulation comes into its own when classes become highly-complex (classes within classes) as each class is responsible only for its own data, not the classes it contains. Structures can be just as complex, but because they don't have the safeguards that can built into classes, it only takes one errant function to unwittingly invalidate data. A well-designed class ensures data validity at all times.
What are the symbols used in flowchart?
There are many symbols used in flowcharting. A flowchart is basically a diagram that shows the steps of a process (or algorithm), connected with arrows to help in showing the order of the steps.
First, think in terms of a list of the "types" of symbols. One such type is "arrows". "Arrows" would have many different symbols associated with it.
This list is certainly not all-inclusive, as there are many types of flowcharts, each with its own special application. The list above is from "older basic computer science textbooks," so it has many types of symbols related to computer processes.
So we conclude that there really is no such thing as a single list of symbols. But don't give up!
The most commonly used symbols are:
A program written in a high-level programming language is called?
the program written in high level language is called "source program"