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

Why c compiler creates exe file?

(Actually, it is the linker, not the compiler.) In most cases, when you write a program, it's not only for your own pleasure, but you actually want to run the program. Well, the runnable format of the program is the exe(cutable).

Write a c program to print the following pyramid 1 121 1231 12321 1234321?

To print the given pyramid pattern in C, you can use nested loops. The outer loop controls the rows, and the inner loop controls the numbers to be printed in each row. Here's a simple C program to achieve this:

#include <stdio.h>

int main() {
    int rows = 5;
    
    for (int i = 1; i <= rows; i++) {
        for (int j = 1; j <= i; j++) {
            printf("%d", j);
        }
        for (int j = i - 1; j >= 1; j--) {
            printf("%d", j);
        }
        printf("\n");
    }
    
    return 0;
}

This program will output the desired pyramid pattern.

What numbers have only one array?

1,7,11,

Well, it depends on what you mean by 'the array of a number'. If it has something to do with the divisors, then it's the primes, or the powers of primes.

Write the algorithm and draw the flowchart to find Sum of N Prime number?

Ah, finding the sum of N prime numbers is a lovely challenge! You can create an algorithm by first defining a function to check if a number is prime, then loop through numbers starting from 2 and add the prime numbers to a running sum until you reach N prime numbers. For the flowchart, you can start with a start/end symbol, then use decision symbols to check if a number is prime, loop symbols to iterate through numbers, and a process symbol to calculate the sum. Remember to add symbols for input and output as well. Happy algorithm painting!

W difference between a linear linked list and a circular linked list?

I would say that there is no such thing as a circular queue. The point of a circular data structure is to allow the end to loop around to the beginning. Since you can only remove items from the beginning of a queue or add them to the front, having these two items linked has no purpose nor benefit.

What is the difference between predefined functions and user defined functions?

Predefined functions are built-in functions provided by a programming language or software application for common tasks, such as mathematical calculations or string manipulation. User-defined functions are functions created by the programmer to perform specific tasks tailored to the program's requirements. Predefined functions are readily available and can be used without additional coding, while user-defined functions require the programmer to define the function's behavior and implementation.

How do you map the object oriented concept using non object oriented languages?

Object oriented programming doesn't strictly require an object-oriented programming language (although those are generally best suited for the job).

Object orientation, as a concept, means to create logical representations of physical or conceptual items: a vehicle, a person, a manager, etc. Each object type (commonly called a class) has a bundle of attributes (data items, properties) and verbs (methods, functions). These bundles, together, form the class.

It is thus possible to create constructs very close to modern classes as those known in C++ using structures in C. In fact, the first C++ compilers (~20 years ago) translated C++ into C, then used an existing C compiler to generate executable code.

In C, a structure can

  • contain variables (data members)
  • pointers to functions (member functions)
  • pointers to pointers of functions (virtual functions)

Among the many standard object-oriented techniques which can not be modeled in C are

  • privacy through visibility keywords (public, private, protected)
  • inheritance (but a "derived" class can embed the "superclass" for a similar effect)
  • polymorphism
  • contracts (interfaces)
  • operator overloading

That said, object orientation as a design concept does not require an object oriented language.

When the program size is larger than the RAM size how will the program get executed?

The simple answer is it won't execute at all. If a program cannot fit into the system's physical memory (RAM) then it cannot execute, period. The solution is to modularise the program such that the executable is small enough to remain resident while auxiliary functions are placed in more transient libraries that can be freely loaded and unloaded as and when required.

Although virtual memory can make it appear as if your system has far more memory than physically exists in the system, there are still limitations. For example, a 32-bit Windows operating system has a maximum address space of exactly 4 GB (2^32 = 4,294,967,296 bytes), but a single process can only utilise 2 GB at most -- the other 2 GB is reserved for use by the system. Thus the largest executable is limited to no more than 2 GB in size. However, the actual limit is less than 2 GB because the size of the executable on disc is (usually) much lower than its runtime size. This is because every process requires at least one fixed-length call stack (one for each thread of execution in the process) and the process' data segment can generate all zero-initialised static variables, constants and globals at loadtime (they are not stored in the executable, unlike non-zero-initialised statics are), not to mention anonymous variables that are generated on the heap at runtime.

For 64-bit systems, although the theoretical address space is 2^64 = 18,446,744,073,709,551,616 bytes (18 exabytes), that's far more memory than physically exists on the planet! With current technology it is simply not possible to design a system that can accommodate the full complement of memory, thus there has to be a more practical physical limitation. In the case of Windows 10 x64, the physical limit is 2 TB (or 128 GB in the case of Windows 10 Home edition). Even the virtual address space must be limited and this is set at 8 TB for x64 processes (or 7 TB for Intel Itanium-based systems) and 128 TB for Server editions.

What are the limitations of getchar and scanf functions for strings?

cause getchar only read a character and scanf read only word before first space but not other words and letters.

At what time is the sum of the digits on a digital clock the greatest?

The sum of the digits on a digital clock is the greatest when the time is 9:59. At this time, the sum of the digits is 9 + 5 + 9 = 23. This is the highest possible sum because the maximum value for each digit on a digital clock is 9.

How do you draw a flowchart to find the maximum and minimum of three numbers?

1.draw circle and write START

2.draw the parallelogram and pass the input as A,B,C

3.after this draw decision box i.e diamond shape and write(Is A> B) then make two lines attached to the decision box i.e for true or false. 4.if it is true then make another diamond shape and write(Is A> C) and if it is false then make another diamond shape and write(B > C)

5. if the ( A> C) then print number A is maximum or if (B>C) then print number B is maximum

6.and if both the condition are false then display C is maximum number

7.draw the circle and write STOP

this is flow chart to find maximum of 3 number

hope it will helpful for u

thank you

Harshala Kadam

Write an algorithm that can find the maximum of n numbers?

#include void main()
{
int a[10] = { 4, 55, 65, 73, 87, 99, 45, 454, 4353, 243}; int i, j, k, l; for ( j = 9, i = 1, k = 5, l = 6; i <= 2, k >= 3, l<= 7, j >= 8 ; i++, j--, k--, l++)
{

if (a[0] < a[i])
{
a[0] = a[i];
}
if (a[0] < a[j])
{
a[0] = a[j];
}
if (a[0] < a[k])
{
a[0] = a[k];
}
if (a[0] < a[l])
{
a[0] = a[l];
}
} printf("highest number = %d", a[0] );
}

What is all the arrays for 12?

Oh honey, there are so many arrays for 12, it's like trying to count all the wrinkles on my face! Let's see, you've got 1 x 12, 2 x 6, and 3 x 4. But hey, if you want to get fancy, you can also do 4 x 3, 6 x 2, and 12 x 1. Math can be a real party sometimes!

What is the relationship between ICT and computer?

Information and Communication Technology (ICT) is a broad term that encompasses the use of various technologies for communication and data processing. Computers are a key component of ICT, as they are used for processing and storing data, as well as for communication through networks. In essence, computers are a fundamental tool within the realm of ICT, enabling the processing, storage, and transmission of information across various digital platforms.

What is the opposite of primitive?

The opposite of primitive is advanced or sophisticated. Primitive refers to something basic, undeveloped, or in its earliest stage of existence. In contrast, advanced denotes a higher level of complexity, refinement, or progress in a particular field or context.

How to draw Flowchart to print prime numbers from 1 to 100 using while loop in c language?

Oh, dude, drawing a flowchart for printing prime numbers from 1 to 100 using a while loop in C? That's like asking me to explain quantum physics while juggling flaming torches. But hey, you basically start with a start symbol, then draw a decision box to check if a number is prime, and loop back until you reach 100. Just remember to add some arrows and shapes, and you're good to go!

C plus plus program Code for greatest common factor using prime factorization?

#include

#include

#include

void main()

{

int a,b,c;

clrscr();

cout<<"Enter the first no : ";

cin>>a;

cout<<"\nEnter the Second no : ";

cin>>b;

int k=0;

if(a==0)

{

cout<<"\nGCF : "<

}

if(b==0)

{

cout<<"\nGCF : "<

}

while((a & 1)==0 && (b&1)==0)

{

a>>=1;

b>>=1;

k+=1;

}

do

{

if((a & 1)==0)

{a>>=1;}

else if((b & 1)==0)

{b>>=1;}

else if(a>=b)

{a=(a-b)>>1;}

else

{

b=(b-a)>>1;

}

}while(a>0);

cout<<"\nGCF : "<

getch();

}

Which number between 1 and 5 can array 3 times?

Please improve your question so we do not have to guess at what you are asking.

Is this a math, c Programming or algebra problem, please pick one because it cannot be all 3 at the same time.

Evaluate a post fix expression?

Okay, here is a postfix expression:

3 4 * 5 6 * +

the evaluation:

3*4 + 5*6

12 + 30

42

How do you convert decimal 23 from binary to decimal?

To convert a decimal number to binary, you simply need to divide by 2 and take note of the remainder.

Example:

23 / 2 = 11 Remainder 1

11 / 2 = 5 Remainder 1

5 / 2 = 2 Remainder 1

2 / 2 = 1 Remainder 0

2 / 1 = 0 Remainder 1

The answer is therefore 10111.

NB: If the question is to answer is 8-bit you must pad it out with zeroes as follows:

00010111

What is the program to input 5 numbers and find maximum of them?

#include

void input(double arr[], const int numElems);

double max(double arr[], const int numElems);

int main()

{

const int numElems = 5;

double arr[numElems] = {0.0};

input(arr, numElems);

std::cout << "Maximum is: " << max(arr, numElems);

std::cout << std::endl;

system("PAUSE");

return 0;

}

void input(double arr[], const int numElems)

{

std::cout << "Enter " << numElems << " elements." << std::endl;

for (int i = 0; i < numElems; i++)

{

std::cout << "Enter " << (i + 1) << " element: ";

std::cin >> arr[i];

}

}

double max(double arr[], const int numElems)

{

double maximum = arr[0];

for (int i = 0; i < numElems; i++)

{

if (maximum < arr[i])

{

maximum = arr[i];

}

}

return maximum;

}

*The code was compiled in VS2008/2010