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

Implementation of index sequential file organization?

Indexed sequential file organization. =In indexed sequential file organization, the records arestored in sequence according to a primary key and an index is created to allow random access of the file. This type of organization also allows the file to be accessed sequentially. Indexed sequential is the most commonlyused type of file organization. writer-k.k.b -montanna

Is a for loop a post-test loop?

Yes. The second clause (the condition) is evaluated before each iteration through a loop. It is possible that a for loop will not execute if its precondition is not met. For example, "for( int x = 5; x < 5; x++ )" will not iterate even once.

Check wheather the strings are equal?

int string_equal (char *p1,char *p2)

{

int status = 1;

while ((*p1 *p2) && status==1)

{

if (*p1++ != *p2++) status = 0;

}

return status;

}

What is the difference between sprintf and fprintf?

sprintf: This Writes formatted data to a character string in memory instead of stdout

Syntax of sprintf is:

#include

int sprintf (char *string, const char *format

[,item [,item]...]);

Here

String refers to the pointer to a buffer in memory where the data is to be written. Format refers to pointer to a character string defining the format. Each item is a variable or expression specifying the data to write.

The value returned by sprintf is greater than or equal to zero if the operation is successful or in other words the number of characters written, not counting the terminating null character is returned. And return a value less than zero if an error occurred.

printf: Prints to stdout

Syntax for printf is:

printf format [argument]...

The only difference between sprintf() and printf() is that sprintf() writes data into a character array, while printf() writes data to stdout, the standard output device

Write a program to find the reverse of a given number with help of function?

//Reverse of the Number

#include<stdio.h>

#include<conio.h>

int main ()

{

int num,mod,rev=0;

printf("Enter a number:");

scanf("%d", &num);

while (num>0)

{

mod=num%10;

rev=(rev*10)+mod;

num=num/10;

}

printf("Reverse of the given number: %d", rev);

getchar();

return 0;

}

// alternative solution based on reversing the alphanumeric representation of

// the number:

void rev(int me) {

char alpha[32];

sprintf(alpha, "%d", me);

for (const char* cp = alpha + strlen(alpha) - 1; cp >= alpha; --cp) {

putchar(cp); }

}

What are sequential access files?

The file(s) (data) which are accessed in a sequential or a orderly manner is called as a sequentially accessing a file.

Write a algorithm to print all even numbers in descending order?

AnswerIf A=10, B=2...

Then the algoritm is :-

STEP1 : START.

STEP2 : A=10.

STEP3 : B=02.

STEP4 : C=A-B.

STEP5 : PRINT C.

STEP6 : STOP.

AnswerYou cannot print every even number in descending order, because there is no greatest even number. Or you want something like this:

infinity

infinity-2

infinity-4

Answerstep 1: start

step 2: Input N

step 3: If N<=1, go to step 5

step 4: if N%2=0, Print N

N=N-1, go to step 3

step 5: End

How do you write a c program sum of all elements from a two dimensional (2D) array?

#include #include voidmain() { int a[10]; int i,sum=0; int *ptr; printf("Enter 10 elements:n"); for(i=0;i<10;i++) scanf("%d",&a[i]); ptr = a; /* a=&a[0] */ for(i=0;i<10;i++) { sum = sum + *ptr; //*p=content pointed by 'ptr' ptr++; } printf("The sum of array elements is %d",sum); }

Difference between include header file in C and import in java?

A) #include makes the C/C++ compiler to physically copy the entire header file code into the 'Cor C++' programs, Thus the program size will increase unnecessarily and hence it takes more memory and memory processor time.
Where as import statement makes the JVM to go to Java Library, execute the code there and substitute the result into the Java program "Here no code is copied"...................................




During compilation an .obj file will be light weight in c where as heavy during execution, which is constrant to the .class file




Sandeep Bandari (Chandurthy,9704740271)

Can a reserved word be used as an identifier name?

Identifiers are a bit more generic in the context of programming.

If you mean, in terms of the C languages (C, C++, C#), the question is the reverse...keywords may NOT be used as identifiers.

For example, you cannot use keywords such as "int", "float", "double", etc. as the names of variables or objects.

5 steps of the program development process?

Programming is a problem-solving activity. A person with good problem solving skills will tend to be a good programmer. To develop this skill, a programmer must practice the following steps:

  1. Problem Analysis
  2. Setting up an algorithm
  3. Coding
  4. Encoding
  5. Running, testing and debugging
  6. Documentation

Write a prog to find length of string using strlen function?

void main()

{

char str1[30];

char str2[30];

int len1,len2;

printf("Enter string1......:");

gets(str1);

printf("Enter string2......:");

gets(str2);

len1=strlen(str1);

len2=strlen(str2);

printf("%s length = %d",str1,len1);

printf("%s length = %d",str2,len2);

}

How to convert From human language to computer language?

Depending on what you're looking at, you may not be able to. My suggestions would be to find the appropriate program used to edit the type of file you're looking at, or to try to find a decompiler for the programming language the file corresponds to.

How do you write linked list program?

a Linked List is a Linear collection of self refrential -class objects, called Nodes that's in General. but if you are using Java You can build it Like That.. http://www.cs.fiu.edu/~weiss/dsj3/code/weiss/nonstandard/LinkedList.java if you are using C++ this Link will be helpful http://richardbowles.tripod.com/cpp/linklist/linklist.htm it covers the ideas of a linked list that what i used (C++,Java) i don know what about C# maybe other contributors can help...

Program to print sorting of an array in clanguage?

/* PROGRAM TO SORT ARRAY ELEMENTS USING BUBBLE SORT*/ #include #include void main() { int i,j,n,t,a[50]; clrscr(); printf("ENTER THE ARRAY SIZE:\n"); scanf("%d",&n); printf("ENTER THE ARRAY ELEMENTS:\n"); for(i=0;i

Difference between syntax error and runtime error?

Syntax error can be found during compilation. Runtime error can be found only when you are trying to execute your program.

Syntax errors are those which are caused by incorrect usage of the programming language. All programming language compilers are designed to detect and report such errors done by the programmer

Runtime errors are those which are caused by incorrect usage of programming logic. for example a runtime divide method will throw a run time error if the divisor is '0' because numerically you cannot divide a number by 0

How do you start array list from 1?

Array indices are zero-based because the first element is at offset zero from the start of the array. There is no such thing as a one-based array in C. Some other languages do allow you to specify the base of an array, but converting a non-zero-based index to a zero-based index adds a runtime overhead to the implementation.

Strengths and weaknesses of the C language?

  • Well, I program in C++, and really isn't something you can't do. At least it is the most flexible programming language. If you want something flexible, take C. And I'll give you some more advice: Take C++. C has some really annoying things that C++ fixes. There really aren't limitations. And C and C++ are good. They're the ones you'd start out with, and the ones I'm continuing in, but if you really liked classes in C, you could try Java. It's really class - based.

    -YMT Yusuf E

What is queue explain the basic element of queue?

The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. Following are the types of queue: Linear queue Circular queue Priority queue Double ended queue ( or deque )

How many bytes in long?

The set of datatypes and the definition of each member is dependent on hardware, the language standard, and the language implementation. Not knowing which language the question relates to is particularly limiting.

In Java, a long consists of 8 bytes. This is also generally true for C and C++, depending upon the compiler used. See the related links for further details.

What are the four types of grammars used in compiler?

-Single pass compiler

-Multi pass compiler

-Cross compiler

-Optimizing compiler