answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

Could macro be different software?

Your question has no meaning, but if you wanted to ask whether the preprocessor can be not part of the actual compiler, then the answer is yes, in unix there is a separate program (cpp) that does the preprocessing.

How to find the factorial using stacks?

You don't actually have to use a stack, but if your teacher wants that, you can please them:

int fact (int n)

{

int i, fct;

whatever_stack_type_you_have s;

initialize_your_stack (s);

push (s, n);

for (i=1, fct=1; i<n; ++i) fct *= i;

pop (s, &n);

fct *= n;

destroy_your_stack (s);

return fct;

}

What is branching instruction?

im am sick of all of this mess save me now send this to the next ten people

this is a actual question answer it dumb dumb

In language C these are: goto, return, continue, break

Definition of state variable?

Any variable, which holds a value that represent the state of something, like:

int door_is_open; /* 0/1 = closed/opened */

What is a format of cost statement?

No such statement. You may want to ask about the 'const' type-modifer.

C program to find out largest and smallest in a list of given numbers using arrays?

#include <iostream>

using std::cout;

using std::cin;

using std::endl;

int main()

{

int max;

int num;

for (int counter = 0; counter<15; counter++)

{

cout <<"Enter a number: ";

cin >> max;

cout << "Enter another number: ";

cin >> num;

if (num > max)

num = max;

cout << "The largest number is " <<max;

}

return 0;

}

How do you access an object file?

These files are produced as the output of the compiler. They consist of function definitions in binary form, but they are not executable by themselves. Object files end in ".o" by convention, although on some operating systems (e.g. Windows, MS-DOS), they often end in ".obj".

A c program for multiplication of two integers a and b?

/*PROGRAM TO ACCEPT TWO NUMBERS FROM THE USER AND PRINT THEIR MULTIPLICATION. */

#include<stdio.h>

#include<conio.h>

void main()

{

int a, b, c; // Declaration of Variables. Variables 'a' & 'b' to hold first & second number. And 'c' to hold result.

clrscr(); // To clear the output screen every time program is executed.

printf("\n Enter the first number : ");

scanf("%d", &a); // To accept the first number.

printf("\n Enter the second number : ");

scanf("%d", &b); // To accept the second number.

c = a*b; // Logic to get the product of the entered two numbers.

printf("\n Multiplication of %d & %d = %d", a, b, c); // Displaying result.

getch(); // To hold the output screen.

}

How do you return to a main function?

..use do{} while{}..

for example..

#include
main(){
int choose;
double a,b,c;
printf("Enter 7 if you want to use the calculator. Otherwise,type any character.\n");
scanf("%d",&choose);
do{
if (choose==7){
printf("Press 1 for addition.\n");
printf("Press 2 for subtraction.\n");
printf("Press 3 for multiplication.\n");
printf("Press 4 for division.\n");
scanf("%d",&choose);
if (choose==1){
printf("Enter the addends\n");
scanf("%lf %lf", &a,&b);
c=a+b,
printf("The sum of %lf and %lf is %lf.\n",a,b,c);
}else if(choose==2){
printf("Enter the minuend and subtrahend\n");
scanf("%lf %lf", &a,&b);
c=a-b,
printf("The difference of %lf and %lf is %lf.\n",a,b,c);
}else if(choose==3){
printf("Enter the multipliers\n");
scanf("%lf %lf", &a,&b);
c=a*b,
printf("The product of %lf and %lf is %lf.\n",a,b,c);
}else if(choose==4){
printf("Enter the dividend and divisor\n");
scanf("%lf %lf", &a,&b);
c=a/b,
printf("The quotient of %lf and %lf is %lf.\n",a,b,c);
}else{
printf("You have entered an invalid digit.\n");}
printf("If you want to continue,press 7 and choose again from 1 to 4.\n");
printf("Do you want to exit? Enter any key.\n");
scanf("%d",&choose);
}
}while(choose==7);
}

A stack class template in C?

I didnt get exactly what do you mean by stack class template, but this is one which implements a stack! and also shows how to implement it with templates

http://thetechnofreaks.com/2011/10/26/4-creating-a-stack/#ixzz1bvq2V1Ws

What is the syntax of for loop statement?

syntax: for(initialization;condition;increment) { statements s1; statements s2; } #include<stdio.h> main() { int i,n=5; for(i=0;i<n;i=i+1) { printf("the number s are %d", i); } }

What does entity name mean?

Entity has several meanings but the most common is that of the paranormal entity. In several ghost series such as 'Ghost Adventures', they often refer to 'demonic entities', or spirits that have demon-like characteristics.

Find Nth harmonic number using recursion?

Type this into Dev-C++ and run it. You will be able to find whatever harmonic number you want. This may not be perfect because I wrote it in about 10 minutes, but I think it works just fine. Good luck!



#include

double seq(double x);

double seq(double x) {

double temp=0;

if (x==0)
return 0;


return 1/x + seq(x-1);
}


int main() {

double x, y;

while (x != 0) {

printf("Please enter a number:\n");
scanf("%lf", &x);

y = seq(x);

printf("The sequence of that number is: %lf\n", y);

}


system("PAUSE");
return 0;
}

Can you give alliteration with a c?

cat, Cathrine, Cathy, called, coming, caring, coughed, calmed, crazed, can, clapped, carried, caressed, courage, clasped, and that's all i can think of right now.

View lib file contents?

There is a nice tool for that in http://www.codeproject.com/KB/debug/LibView.aspx

What is the algorithm to count no of nodes in singly linked list?

int numNodes = 0;

Node current = root;

// if root is null, the number of nodes is 0

if(current != null) {

// if root is not null, we have at least one node

numNodes = 1;

// count all nodes

while(current .next != null) {

++numNodes;

current = current.next;

}

}

You must write a program in C that uses a stack to check a file for unbalanced parenthesis any suggestions?

Parse the character stream from the beginning of the sequence to the end, counting characters as you go. Every time you encounter an opening parenthesis, push the current character count onto the stack. Every time you encounter a closing parenthesis, ensure the stack is not empty before popping the top value from the stack. You can discard the value -- you've found a matching pair.

If you attempt to pop from an empty stack, then you have a closing parenthesis at the current character position that has no matching opening parenthesis.

If you reach the end of the test and the stack is not empty, you have at least one opening parenthesis without a matching closing parenthesis. Pop the character positions off the stack to determine where the opening parenthesis are.

What is the difference between data and programs?

Data is the information that a program will act upon. For example, your data might be all of your financial records for the past year, and the program would be some piece of tax software. The program will act upon your data so that the appropriate numbers are placed in the appropriate fields on your tax return.

Write a C program to evaluate the given polynomial fxa4x4 a3x3 a2x2 a1x a0 for given value of x and the coefficients using Horners method using single dimension arrays to store coefficient?

#include #include int main() { int n,i; float a[30],x,sum; printf("Enter the val ue of \'n\'\n"); scanf("%d",&n); printf("Enter \'n+1\' values\n"); for(i=0;i0;i--) sum=(sum+a[i])*x; sum=sum+a[0]; printf("Evaluated result = %f \n",sum); getche(); }

Difference between relational and logical operators?

Logical operators don't Compare values they combine Boolean values and produce a Boolean result. Examples of logical operators are && (and), , (or), ! (not). If you have two Boolean values and you combined them with the && operator the result will be (TRUE) only if both values were (TRUE).

Relational operators compare two values and produce a Boolean result. Most of the time we use logical operators to combine the results of two or more comparison expressions that use relational operators.

Write a program to find a electricity bill?

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,k;

string="electricity";

string="units";

printf("enter the units");

scanf("%d%d%d",&i&j&k);

i=j/k;

printf("ur bill is %d",i);

getch();

}