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

What is the different between header file and header pointer?

Header file is a file which is meant to be included into another file during compilation. Examples: string.h, stdio.h, inttypes.h.

Header pointer is a pointer to an object called header (for example header of a linked list).

Write C program to find the sum of first 100 numbers?

#include<stdio.h> #include<conio.h> void main() { int n; printf("Enter any number"); scanf("%d",&n); sum=((n*(n+1))/2); printf("The sum of first 100 natural numbers is\t%d",sum); }

What is the goal of information processing?

Information processing provides individuals with basic skills to use the computer to process many types of information effectively and efficiently.

Why we avoid goto statement in c?

Edsger Dijkstra said, excessive usage and unstructured usage of goto may:

1. lead to a very bad/un-readable/un-structrured/complicated code

2. increase the complexity of debugging and analyzing the code

.

But there are some hidden-gotos that we use in C language

1. break

2. continue

3. return

.

Rules of thumb:

It is not very bad to use goto in any language if we follow the following rules

1. Always use gotos to jump to a forward location. Gotos are very useful in cleanup activities

2. Backward jump can always be accomplished by using continue inside a loop. This doesn't mean that we shouldn't use backward gotos. Backward gotos can be introduced when the code is very legible and it is not disrupting the structure and readability of the code and there are only a few backward gotos.

3. Use do { .... if(xx) break; ... } while(0); - type of coding will suite to most of the places where we need to use goto.

4. Usage of goto to jump into another code-block/scope is always bad. Instead strucure the code in such a way that goto-lables are placed at the start of the code-block/scope.

5. The primary-advantage of using goto when compared to its alternative ways is, goto is fast.

6. Avoid as much gotos in your code and use goto only when you feel that usage of goto's alternative ways will slowdown the execution or they increase the complexity or decrease the readability.

7. Make sure that usage of goto/break/continue/return is not creating any unreachable code

8. Keep in mind that usage of goto is near to punishable offence w.r.t some organization's/intuition's coding standards.

How do you find out addition of all numbers between two inputed numbers in for loop?

First of all we will describe how our program should be working.

After entering number 1 and 5 I want it count 2 + 3 + 4 and return 9. After entering 4 and 9 it should count 5 + 6 + 7 + 8 and return 26. After entering X and X I should get 0. If I enter X and X - 1 I should get and error.

Here is the code of such application:

#include

int main() {

int firstNum, secondNum, sum, tmp;

printf("Please enter first number: ");

scanf("%d", &firstNum);

printf("Please enter second number: ");

scanf("%d", &secondNum);

if (secondNum < firstNum) {

printf("Sorry, second number must be higher than first one.\n");

return 1;

}

sum = 0;

for (tmp = firstNum + 1; tmp < secondNum; tmp++) {

sum += tmp;

}

printf("All numbers between %d and %d sum equals %d\n", firstNum, secondNum, sum);

return 0;

}

Testing:

Please enter first number: 1

Please enter second number: 5

All numbers between 1 and 5 sum equals 9

Please enter first number: 4

Please enter second number: 9

All numbers between 4 and 9 sum equals 26

What is meant by array loud speaker?

Array speakers, You can see it in the theaters, it is simply a large number of speakers hanging or placed vertically in the wall and it produce a uniform sound. It is used to reach the voice to each and every individual person in that theater.

By regards

udayan AR

When a function is used as an argument in another function?

It is called callback function. For an example see the qsort function.

Is it possible to initialize null character in string?

yes we can initialize null characterfor example syntax :string='\0';

What is the use of extension C?

you can put it to the end of the filename: somesource.c

How do you find flames using string?

I'm not sure what your asking. Is flames another string or the contents of a string?

I can't answer your question because your either asking something way beyond or ask something that has no answer.

Is there any program to write pseudocode?

Yes, this program is the same as flowchart, pseudo code.

http://watts.cs.sonoma.edu/SFC/index.html

another option is to use Note Tab Light and the Pseudo code library.

http://www.notetab.com/libraries.php?cat=scripting

No. Pseudocode is, as the name suggests, not real code. Pseudocode is an abstract concept that is often used in literature to highlight a principle or solution without focussing on the syntax details of a specific computer programming language.

For example, one language might make assignments with the '=' operator, another one might require the use of ':=' or '<-'. Other languages might even control assignments in a totally different way, for example by implication such as in stack-oriented programming languages.

Some languages might provide an "else if" construct to further diversify the else-branch of an if-clause, while others might use the "elif" keyword, or a different construct.

These are syntax details of programming languages, and are often irrelevant when discussing more abstract concepts in a language-independent way. Pseudocode aims to provide an intuitive description. The fact that the reader knows this to be pseudocode means that nobody ought to argue about the position of a semicolon or the use of single versus double quotes; you'd know this is not the real code in any specific language, but probably close for easy implementation at least with functional languages.

For example, when describing a general-purpose algorithm to sort items in a sequential list, pseudocode might say

if a > b then

swap a, b

The reader is required to transcode pseudocode into the specific programming language intented (C, Basic, Pascal, Perl, whatever).

Pseudocode is often used when describing generic algorithms, such as sort algorithms.

How do you hide local variables in c and give precedence to global variables inside the function?

Hi, I would like to answr the question.So, if you want the to give more precedence to global variables with respect to a local one.Just add a pair of curly braces in the local variable and by doing so u can access global variable.

Greatest no among 3 number using nested if statement?

if (a > b && a > c) printf("%d\n", a);

else if (b > c) printf("%d\n", b);

else printf("%d\n", c);

What is looping statement in c language in Punjabi language?

ANSWER in PUNJAbi

22ji e ta bahut sokha hai..

looping statement di help naal asi program de kise v hisse nu vaar vaar chla sakde ha. man lo tussi apna naam 200 vaar print krana hai , ta "printf" command 200 var likhni peni hai, but looping di help naal asi e kam sirf ik vaar "Printf" likh k kar sakde haa. for(i=0; i<200; i++) { printf("gurpreet singh 3184/w"); }

int i=0;

while(i<200)

{

printf("gurpreetsingh3184/w");

i++;

}

What do you mean by operators and operands?

operands are the objects or variable that we create in our program.

operators fuse with the operands to build a mathematical statement in the program.

What is the use of hyperbolic functions?

Hyperbolic functions can be used to describe the position that heavy cable assumes when strung between two supports.

Write a program to calculate the average of n numbers using array?

C:

#include

int main()

{

int num,sum,avg=0,i;

printf("enter a number");

scanf("%d",&num);

for(i=0;i<=num;i++)

{

sum+=i;

avg = sum/num;

printf("%d",avg);

}}

Visual Basic:

Private Function CalculateAverage (ByVal intArray As Integer()) As Integer

Dim intNumber As Double

For i = 0 to intArray.Length - 1

intNumber = intNumber + intArray(i)

End For

intNumber = intNumber / intArray.Count

Return intNumber

End Function