Why do you write your code in a Notepad file?
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.
What is a high level progrmming language?
It is a programming language with strong abstraction from the details of the computer.
A cursor is a moving space, line, arrow, or hand that indicates the position of a text point or GUI location on a computer monitor. Actions taken with the mouse or keyboard will be implemented at the current cursor location.
Some sort of structure that lets you store a list of pending jobs - for example, an array, but it would have to be a resizable array. Some type of collection might be more appropriate. As you process one level of recursion, you add the "children" (which have yet to be processed) to the collection of pending jobs; once the "parent" is done processing, you remove it from the collection.
Write a program that accepts a word in uppercase and prints it in lowercase?
There are two functions in ctype.h: toupper() and tolower(). First one to make character into upper case and the second one for making lower case.
Here is a small program converting inputted character into lower case:
#include
#include
int main() {
char ch;
printf("Enter the char: ");
scanf("%c", &ch);
printf("Char in lowercase: %c\n", tolower(ch));
return 0;
}
Testing:
Enter the char: G
Char in lowercase: g
Enter the char: S
Char in lowercase: s
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));
}
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;
}
Can you use extern and static together?
Storage classes are used to indicate duration and scope of a variable or identifier. Duration indicates the life span of a variable. Scope indicates the visibility of the variable. The static storage class is used to declare an identifier that is a local variable either to a function or a file and that exists and retains its value after control passes from where it was declared. This storage class has a duration that is permanent. A variable declared of this class retains its value from one call of the function to the next. The scope is local. A variable is known only by the function it is declared within or if declared globally in a file, it is known or seen only by the functions within that file. This storage class guarantees that declaration of the variable also initializes the variable to zero or all bits off. The extern storage class is used to declare a global variable that will be known to the functions in a file and capable of being known to all functions in a program. This storage class has a duration that is permanent. Any variable of this class retains its value until changed by another assignment. The scope is global. A variable can be known or seen by all functions within a program.
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 .
Abstract data type that store a whole numbers?
All data types can be used to store a whole number, even the data types that can store a decimal number.
How do you write a C program to print all combinations of a 3-digit number?
Mathematically-speaking there is only one combination of a 3-digit number. When dealing with a combination of digits, the order of those digits does not matter, thus 123 and 321 are the exact same combination. If the order of the digits is important then it is a permutation, not a combination. That is, 123 and 321 are completely different permutations of the same combination of digits.
The confusion is understandable given that we commonly refer to a combination lock instead of a permutation lock. Mathematically speaking, a combination lock that unlocks with the code 123 would also unlock with the codes 132, 213, 231, 312 and 321, because all six permutations of the digits 1, 2 and 3 are in fact the same combination. Some combination locks really do work this way, however the vast majority are actually permutation locks; we call them combination locks simply because we don't normally use the term "combination" in the much stricter mathematical sense.
To restate the question: How do you write a C program to print all permutations of a 3-digit number?
A 3-digit number has 6 permutations, thus we can print all six by treating the number as an array, and printing all 6 permutations of the array:
void print_permutations (int num) { char set[3];
int index;
if (num<100 num > 999) return; // not a 3-digit number
index = 0;
while (num>0) {
set[index] = num % 10; // least-significant digit
num /= 10; // shift all digits one position to the right
}
// sort the array in ascending order
if (set[0]>set[1]) set[0]^=set[1]^=set[0]^=set[1];
if (set[1]>set[2]) set[1]^=set[2]^=set[1]^=set[2];
if (set[0]>set[1]) set[0]^=set[1]^=set[0]^=set[1];
// print the permutations
printf ("%d%d%d\n", set[0], set[1], set[2]); printf ("%d%d%d\n", set[0], set[2], set[1]); printf ("%d%d%d\n", set[1], set[0], set[2]);
printf ("%d%d%d\n", set[1], set[2], set[0]);
printf ("%d%d%d\n", set[2], set[0], set[1]);
printf ("%d%d%d\n", set[2], set[1], set[0]);
}
The problem with this is when the 3-digit number contains duplicate digits. This would treat 100 as if it had 6 permutations when it really only has 3 {100, 010 and 001}, while 111 only has one permutation {111}. These must be treated as being special cases:
void print_permutations (int num) {
char set[3];
int index;
if (num<100 num > 999) return; // not a 3-digit number
index = 0;
while (num>0) {
set[index] = num % 10; // least-significant digit
num /= 10; // shift all digits one position to the right
}
// sort the array in ascending order
if (set[0]>set[1]) set[0]^=set[1]^=set[0]^=set[1]; // move larger of 1st and 2nd digit to middle
if (set[1]>set[2]) set[1]^=set[2]^=set[1]^=set[2]; // move larger of 2nd and 3rd digit to end
if (set[0]>set[1]) set[0]^=set[1]^=set[0]^=set[1]; // move larger of 1st and 2nd digit to middle
// print the permutations (handle special cases where digits are duplicated)
if (set[0]==set[1] && set[0]==set[2]]) { // same three digits (one permutation)
printf ("%d%d%d\n", set[0], set[1], set[2]);
} else if (set[0]==set[1]) { // first two digits are the same (three permutations)
printf ("%d%d%d\n", set[0], set[1], set[2]); // same as 1, 0, 2
printf ("%d%d%d\n", set[0], set[2], set[1]); // same as 1, 2, 0
printf ("%d%d%d\n", set[2], set[0], set[1]); // same as 2, 1, 0
} else if (set[1]==set[2]) { // last two digits are the same (three permutations)
printf ("%d%d%d\n", set[0], set[1], set[2]); // same as 0, 2, 1
printf ("%d%d%d\n", set[1], set[0], set[2]); // same as 2, 0, 1
printf ("%d%d%d\n", set[2], set[1], set[0]); // same as 1, 2, 0
} else { // all three digits are unique (6 permutations)
printf ("%d%d%d\n", set[0], set[1], set[2]);
printf ("%d%d%d\n", set[0], set[2], set[1]);
printf ("%d%d%d\n", set[1], set[0], set[2]);
printf ("%d%d%d\n", set[1], set[2], set[0]);
printf ("%d%d%d\n", set[2], set[0], set[1]);
printf ("%d%d%d\n", set[2], set[1], set[0]);
}
}
How does a natural arch change into a stack?
the sea erodes the stack to such a point until the wasn't enough suport and the roof colapsed making the arch become a stack.
Write a c program to print the following output using for loop 1 2 2 333 4444 55555?
int main()
{
int i,j,sum,k;
for(i=1;i<=5;i++)
{
k=1;
sum =0;
for(j=1;j<=i;j++)
{
sum = sum+(i*k);
k=k*10;
}
cout<< sum;
cout<< "\n";
}
}
What is the difference between nodes and inter node?
The node is the part of the stem of the plant from which leaves, branches, and aerial roots emerge.
There are many nodes on a plant stem. The distance between each node is called the inter node.
What are the Various compilers of different language?
A program that translates source code into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instructions. Thus, a compiler differs from an interpreter, which analyzes and executes each line of source code in succession, without looking at the entire program. The advantage of interpreters is that they can execute a program immediately. Compilers require some time before an executable program emerges. However, programs produced by compilers run much faster than the same programs executed by an interpreter.
Every high-level programming language (except strictly interpretive languages) comes with a compiler. In effect, the compiler is the language, because it defines which instructions are acceptable.
Because compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language. For example, there is a FORTRAN compiler for PCs and another for Apple Macintosh computers. In addition, the compiler industry is quite competitive, so there are actually many compilers for each language on each type of computer. More than a dozen companies develop and sell C compilers for the PC.
Write a c program to generate student mark details using union and find total and average and grade?
write a c program to display marks,total,average,grade using union
auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while
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.
What is the difference between argument and parameter?
The term parameter refers to any declaration within the parentheses following the function name in a function declaration or definition; the term argument refers to any expression within the parentheses of a function call.
1.parameter used in procedure defination
2.arguments used in procedure call
This example demonstrates the difference between a parameter and an argument:
void foo(int a, char b); //a and b are parameters,
here procedure is define
int main()
{
foo(5, 'a'); //5 and 'a' are arguments,
here procedure is called
return 0;
}
Different types of sorting techniques in c language?
types of sorting in c language are:
insertion sort
selection sort
bubble sort
merge sort
two way merge sort
heap sort
quick sort
How do you run c program in dos prompt?
Compile it, link it to an executable, then just enter its name and it starts running.