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

Difference between c plus plus class and c structures?

The definition of the structure in C is limited to within the module and cannot be initialized outside its scope. Where as in C++ you can initialize the objects anywhere within the boundaries of the project.

Short int and long integers have how many bytes in C programming?

It depends on the programming language, the compiler, and the machine architecture.

In C, the size of short int and int is not mandated by the language. Often, on 32-bit machines, 'int' will be 32-bit, while 'short int' may be 16-bit. But the only thing the language promises is that short int will be no larger than int.

What character is used in an OR operator?

The logical OR operator in C and Java is the double vertical bar ().

Example: if (s 0) do something

The operator applies a logical OR operator when it evaluates the expression.

Write a program that checks whether given number is perfect or not?

#include<stdio.h>

#include<conio.h>

void main()

{

int n,i,r,count=0;

clrscr();

printf("Enter a number");

scanf("%d",&n);

for(i=2;i<n;i++)

{

r=n%i;

if(r==0)

{

count++;

break;

}

}

if(count==0 && n!=1)

{

printf("It is a prime number");

}

else

{

printf("It is not a prime number");

}

getch();

}

Why is an array called a data structure?

An array could be called static because it is generally not changed structurally once it is created, meaning that you do not add, delete or swap the nodes themselves, though you will likely modify the data contained by the nodes. This differs from a more dynamic data structure, such as a linked list, where adding, deleting or swapping nodes is relatively simple.

What is the difference between array element and variable?

Array is the set of an multiple values where as variable can store single value at a time.

• The difference between the definition of array and ordinary variable is the, array is always declared, initialized, and accessed using subscript whereas ordinary variable do not have any subscript.

• The syntax for ordinary variable definition is data_type v1, v2, ….;

• And the syntax for array variable is data_type v1[N1],v2[N2],…; where v1,v2 are name of variable and N1, N2 are the integer constants indicating the maximum size of array.

What is a program to print the Fibonacci series in c plus plus?

Yes, you can. To generate the Fibonacci sequence, you start with the first two numbers in the sequence, usually 0 and 1. The remainder of the sequence is the sum of the previous two numbers in the sequence:

The following function will generate n terms of the sequence using first and second as the first two numbers in the sequence:

void fibonacci (int n, int first=0, int second=1) {

for (int term=0; term

int sum = first + second;

printf ("%d, ", first);

// prepare for next iteration...

first = second;

second = sum;

}

printf ("\b\b \n"); // backspace over final comma and overwrite with space

}

What is a C?

C is the third letter of the English alphabet. It is from the Latin letter C, which in old Latin represented the sounds of k, and g (in go); its original value being the latter. In Anglo-Saxon words, or Old English before the Norman Conquest, it always has the sound of k. The Latin C was the same letter as the Greek /, /, and came from the Greek alphabet. The Greeks got it from the Ph/nicians. The English name of C is from the Latin name ce, and was derived, probably, through the French. Etymologically C is related to g, h, k, q, s (and other sibilant sounds). Examples of these relations are in L. acutus, E. acute, ague; E. acrid, eager, vinegar; L. cornu, E. horn; E. cat, kitten; E. coy, quiet; L. circare, OF. cerchier, E. search., The keynote of the normal or "natural" scale, which has neither flats nor sharps in its signature; also, the third note of the relative minor scale of the same., C after the clef is the mark of common time, in which each measure is a semibreve (four fourths or crotchets); for alla breve time it is written /., The "C clef," a modification of the letter C, placed on any line of the staff, shows that line to be middle C., As a numeral, C stands for Latin centum or 100, CC for 200, etc.

Difference between direct sequential file and index sequential file?

Explain the difference between sequential and direct file access.

A. Sequential access to data is used when the data has to be read from the start, in sequence. It is the normal method of access for magnetic tape. Direct access is used when it is possible to jump directly to a file or data item without reading through all the items stored before it. This is the normal method used for hard disks.

What is the difference between String and String Buffer?

In Java, String is a class that represents an immutable string, that is a sequence of characters that can never change. Any modification to the String will have to create a new String object. A StringBuffer (and in Java 1.5 and up, a StringBuilder) is a mutable string object that can be modified at runtime.

The advantages of using Strings are that the String is generally lighter and faster to use where the String isn't going to change. When building a long String of text by making changes to one object over time, you should use a StringBuilder or StringBuffer (in Java 1.4 or when synchronization is important).

What are some basic programs in c language?

Traditional C programming follows the ECLG cycle: Edit (the source code), Compile (the program), Link the application and Go run it.

In truth, the ECLG cycle is a (ECLD)*CLG cycle: Edit, compile, link and debug. Repeat this until satisfied with the correct function, the create the final application with another compilation and linkage, and Go (ship, etc).

Write a program in C to find the factoial of 5?

/* gcc -ansi -Wall -Wextra -pedantic -s -static 0.c -o 0 */

#include <stdio.h>

int main ( )

{

int n = 5 , factorial = 1 ;

while ( n != 0 )

{

factorial *= n ;

n -- ;

}

printf ( "%i\n" , factorial ) ;

return 0;

}

What is sub-algorithm?

It is an algorithm used by another algorithm as part of the second algorithm's operation.

As an example, an algorithm for finding the median value in a list of numbers might include sorting the numbers as a sub-algorithm: There are plenty of algorithms for sorting, and the specifics of the sorting does not matter to the "median value" algorithm, only that the numbers are sorted when the sub-algorithm is done.

For what an algorithm is, see related link.

How do you Write a C program for performing as calculator?

#include<stdio.h>

#include<conio.h>

void tax caluclation()

{

char name[20];

double sal,tax;

clrscr();

printf("enter the name of the person:\n");

scanf("%s",name);

printf("enter the name of the person:\n");

scanf("%lf",sal);

if(sal<=75000)

tax=sal*12.0/100;

else

tax=sal*16.0/100;

printf("the tax amount for %s is:%lf\n",name,tax);

}

void main()

{

tax caluclation();

}

no space b/w (tax caluclation) taxcaluclation

What is the difference between extern and global?

Extern and Global are the storage space in C program.

Global provides us to access the variables from anywhere inside the program only whereas Extern provides us to access the variables from outside that program, i,e., some other program.

Why do you use a void pointer in a programme?

void is type of pointer that usually means that you can make it point to any data type.

When you make a pointer point to somewhere its data type should match with the place where you want it to point.

When you dont know the data type where it will point to then you can declare a void pointer and make it point to the data type it want.

Write a c programme to find sum of individual digits of a given positive integers?

int sumDigits(int n) {
int sum = 0;

while( n > 0 ) {
sum += (n % 10); // add last digit of n to sum
n /= 10; // divide n by 10 to "chop off" the last digit

}

return sum;

}

____________________________________________________

C program to find the sum of entered digit: By Jatinder Pal Singh

#include
#include
void main()
{
clrscr();
int n,num,x,sum=0;
printf("Enter a number=");
scanf("%d",&n);
while(n>0)
{
x=n%10;
sum=sum+x;
n=n/10;
}
printf("Sum of digits of a number=%d",sum);
getch();
}

Write a c program to find the roots of a quadratic equation using if else?

/*Hello!! I'm aditya From Bangalore I have the solution of this program*/

#include <stdio.h>

#include <math.h>

main()

{

float a,b,c,x1,x2,delta=0;

printf("enter the value of a,b,c\n");

scanf("f%f",&a,&b,&c);

delta=((b*b)-(4ac));

if(a=0)

{

printf("the variables cannot form a quadratic equation\n");

}

else

{

x1=(-b)+(sqrt(((b*b)-(4ac))/2a))

x2=(-b)-(sqrt(((b*b)-(4ac))/2a))

}

if(delta=0)

{

printf("the roots are real and equal");

}

if(delta>0)

{

printf("the roots are real and distinct");

}

if(delta<0)

{

printf("the roots are imaginary");

x1=(-b)+(sqrt(((b*b)-((4ac))/(float)(2a))

x2=(-b)-(sqrt(((b*b)-((4ac))/(float)(2a))

}

printf("the roots of the equation are %2.2f\n",x1,x2,delta);

}

/*the program is written by using simple-if and if-else constructs*/

Types of array in data structures?

There are many types of trees:

- binary trees

- binary search trees

- B+ trees

- red-black trees

- AVL trees

- suffix trees

- and much more....

Each have different rules for adding a new element, removing an element, and searching for an element in the tree. Consequently, they all have different advantages and disadvantages.

Write in intractive program to generate the divisors of a given integer in c?

#include <stdio.h>

void div(int n){

int i=2;

while(n%i!=0 && i!=n){

i++;

}

printf("%d ",i);

if(i!=n){

div(n/i);

}

}

main(){

int i;

printf("Enter number:");scanf("%d",&i);

printf("1 ");

div(i);

}

What is the c plus plus code for application of linked list in mobile phones?

If people started writing these codes here, then what software engineers will do?

What Machine language is an example of a high-level language.?

There is no program that can translate machine code to a high-level language. The best you can do is disassemble the code. This produces code that is similar to assembly language, but which lacks variable names and comments. Even a skilled programmer will need to spend hours disentangling the code in order to make it readable -- but you can never restore the code back to its original source code, no matter what language it was written in.

What is the function of the loop of Henie?

well urea salts crap like that is filtered through the glomerus were it then becomes filtrate (made up of the urea slats i think glucose too) it then travels down the loop of henley where the glucose is reabsorbed by the blood but the waste product are carried off to the bladder :)