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

C program - to perform matrix addition?

M

#include<stdio.h>

#include<conio.h>

int main()

{

int a[3][3], b[3][3], sum[3][3], i,j;

clrscr();

printf("Enter the first matrix");

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

for(j=0;j<3;j++)

scanf("%d", &a[i][j]);

printf("Enter the second matrix");

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

for(j=0;j<3;j++)

scanf("%d", &b[i][j]);

printf("\nThe first matrix is \n");

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

{

printf("\n");

for(j=0;j<3;j++)

printf("%d\t", a[i][j]);

}

printf("\nEnter the second matrix");

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

{

printf("\n");

for(j=0;j<3;j++)

printf("%d\t", b[i][j]);

}

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

for(j=0;j<3;j++)

sum[i][j]=a[i][j]+ b[i][j];

printf("\n The addition of two matrix is \n");

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

{

printf("\n");

for(j=0;j<3;j++)

printf("%d\t", sum[i][j]);

}

getch();

return 0;

}

What are legal variable names and declarations in c and c plus plus?

Any name that is not a reserved word can be a legal variable, function or type name. All names must be alphanumeric, but they cannot begin with a digit. The C++ standard recommends that all user-defined names be written entirely in lower case with underscores for spaces. Some programmers prefer 'camel case' (such as PrintObject and MaxNumber), which was a popular convention amongst the Pascal programming community, however print_object and max_number are the C++ conventions. Names in all caps are typically reserved for macro definitions (which is effectively a separate language from C++ itself), while names with leading underscores should generally be avoided as this convention is utilised extensively within the standard library.

Why int take 2 byte of memory in c?

Platform dependent, use sizeof (int). You may want to use types int8_t, int16_t, int32_t or int64_t from inttypes.h,theirs sizes are predefined (1, 2, 4 and 8 bytes).

What are all the arrays of 24?

You people are crazy now adays!:) lol

10 When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

As for pointers, I think you have to readjust them. Pointers are just variables that store a memory address in them. You can have as many pointers that point to a single location in memory as you want.

What is a recursive rule?

It is a term for sequences in which a finite number of terms are defined explicitly and then all subsequent terms are defined by the preceding terms.

The best known example is probably the Fibonacci sequence in which the first two terms are defined explicitly and after that the definition is recursive:

x1 = 1

x2 = 1

xn = xn-1 + xn-2 for n = 3, 4, ...

How switch function differs from user defined functions in C?

. please give me 3 or 4 differences.one difference is that user defined can be called anytime but not for switch

There is no such thing as 'switch function'

What c plus plus programming statements to implement data abstraction?

Data abstraction is a design concept, whereby interfaces and implementations are kept separate. That is, it should not be necessary to know how an object works in order to use it. The interface provides all you need to know.

This reflects much of real life. When watching TV, you have a remote control which allows you to select a channel, but it is not necessary to know how the TV receives and processes radio signals, nor how it separates one channel from another. Those are implementation details that are only of concern to TV engineers.

In C++, there are no statements as such to implement data abstraction. You achieve it by designing a public interface which is accessible to normal users, and a private interface that is only accessible to the class designer.

Algorithm of Fibonacci series in c?

#include<stdio.h>

#include<conio.h>

int fib(int a);

main()

{

int a;

clrscr();

scanf("%d",&a);

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

printf("%d\n",fib(i));

}

int fib(int a)

{

if(a==0)

return 0;

if(a==1)

return 1;

else

return (fib(a-1)+fib(a-2));

}

Write a program to display a content of a queue?

This is really dependent how your queue is implemented. Unfortunately, working from the outside of a queue, this is usually impossible without removing all elements from the queue.

while !queue.isEmpty() print queue.dequeue()

How do you write a c program to convert binary to decimal using stack?

ALGORITHM: function outputInBinary(Integer n) Stack s = new Stack while n > 0 do Integer bit = n modulo 2 s.push(bit) if s is fullthen return error end if n = floor(n / 2) end while while s is not empty dooutput(s.pop()) end while end function

Why is so much attention today focused on object-oriented programing in general and c plus plus in particular?

Actually, there is not that much attention today paid to object-oriented programming. It is not a new technology. It is more than 15 years old, and the design paradigm of object-oriented design and object-oriented programming is relatively well established.

Where the attention today is focused is more on multi-threaded programming. The reason for this is that today's processors are approaching the point where Moore's Law is starting to flatten out, i.e. we are approaching the limits of performance gains in a single processor as technology advances.

Many modern computers solve this problem by having more than one processor. Some have many, even thousands or more, such as in a modern supercomputer. The problem is that it is very difficult to write algorithm's that can adequately take advantage of that parallelism. We tend to think linearly, and our algorithms follow that thinking. Such a linear process, however, can only use one processor at a time. We need to work on algorithms that can utilize all of the available processors in a computer at the same time.

Two "yesterdays" ago, the challenge was Block Structured Programming. One "yesterday" ago, the challenge was Object Orientation. "Today", the challenge is Multi-Threading.

Write a Flowchart for Fibonacci series?

1.start

2.a=0,b=1,c and counter

3.display a

4.display b

5.c=a+b

6.display c

7.a=b

8.b=c

9.check whether number is less than the last number you have

if yes than go to step 5

if no stop it

How do you make an program in object oriented programming?

Object Oriented Programming is the technique to create programs based on the real world..object oriented programming model programs are organized around objects and data rather than actions and logic. In OOP based language the principal aim is to find out the objects to manipulate and their relation between each other.OOP offers greater flexibility and compatibility and is popular in developing larger application.

What is a structure in c language and what are its uses?

A structure is a collection of data (variables) with some common meaning or semantical link meaningful to the programmer. They don't have any meaning to the PC (though their use influences the flow of your program).

In general, it is easier to simply collect information in a structure - for example, the width and height of an image, or the first/last names and addresses of customers. It's just easier to think that way, because things in life tend to have relations to each other.

What is the INT functions?

The INT function is to convert something into an integer. An integer is a number that goes out two decimal places.

What is variable data?

A variable data is anything that won't necessarily be the same every time you run a computer program. It may come from user input, from a random function, from consulting a database, etc.

What is the Difference between features and attributes?

Functionality refers to how well something works.

Features refer to what something can do.

A Feature is a sub-system or facility that in included within a larger system.

A Function is the an action that can be performed within the system. Many Functionalities are enabled through a Feature.

For instance, User Administration is a feature offered in Windows. Add User, Grant Privilege to User, Delete User, List Users, etc. are Functions enabled by the User Administration feature.

What is stream in C plus plus?

It's a bit difficult to show a class hierarchy using unformatted text alone, so I'll use the scope resolution operator to show the relationships instead.

Note: [] denotes multiple inheritance

ios_base

ios_base::ios

ios_base::ios::istream

ios_base::ios::ostream:

ios_base::ios::istream::ifstream

ios_base::ios::ostream::ofstream

ios_base::ios::[istream/ostream]::iostream

ios_base::ios::[istream/ostream]::iostream::fstream

ios_base::ios::[istream/ostream]::iostream::stdiostream

ios_base::ios::[istream/ostream]::iostream::stringstream

streambuf

streambuf::filebuf

streambuf::stdiobuf

What is a token in c?

Anything that you can't put whitespace between. The indivisible elements of a program.

Example: printf("Sup world %d",variable);

Tokens: (7 total)

printf

(

"Sup World %d"

,

variable

)

;

What do you call a person who is addicted to computer programming?

One thing that you can call a person that is addicted to computer programming is a computer nerd. A computer nerd is always on the computer.