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

Explain the meaning of polymorphism describe how polymorphism is accomplished in C taking a suitable example?

Polymorphism in VC++ is the same as polymorphism in C++ itself. When you implicitly call a virtual method of a base class or one of its derivatives, then you rightly expect the most-derived override to execute instead, even when the runtime type is completely unknown to the caller and cannot be determined at runtime let alone compile time. You get that for free simply by overriding the known virtual methods of the base class, and without any need for expensive runtime type information, which is only useful if the caller is actually aware of the type in the first place, and which can only be predicted on a closed system. The whole point of polymorphism is that the base class (and therefore the caller) need know nothing whatsoever about any of its derivatives in order to execute more specialised methods. VC++ fully supports this aspect of OOP.

Program to find the sum and difference of two matrices?

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int a[10][10],b[10][10],c[10][10],m,n,i,j;

cout<<"Enter number of rows: ";

cin>>m;

cout<<"Enter number of coloumns: ";

cin>>n;

cout<<endl<<"Enter elements of matrix A: "<<endl;

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

{

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

{

cout<<"Enter element a"<<i+1<<j+1<<": ";

cin>>a[i][j];

}

}

cout<<endl<<"Enter elements of matrix B: "<<endl;

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

{

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

{

cout<<"Enter element b"<<i+1<<j+1<<": ";

cin>>b[i][j];

}

}

cout<<endl<<"Displaying Matrix A: "<<endl<<endl;

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

{

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

{

cout<<a[i][j]<<" ";

}

cout<<endl<<endl;

}

cout<<endl<<"Displaying Matrix B: "<<endl<<endl;

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

{

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

{

cout<<b[i][j]<<" ";

}

cout<<endl<<endl;

}

cout<<endl<<"Matrix A + Matrix B = Matrix C: "<<endl<<endl;

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

{

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

{

cout<<a[i][j]+b[i][j]<<" ";

}

cout<<endl<<endl;

}

getch();

}

C program to multiply two numbers without using arithmetic operator and using recursive function?

# include<stdio.h>

main()

{

int a,b,i:

int result=0;

printf("enter two numbers to be multipied");

scanf("%d%d",&A,&B);

for(i=1;i<=b;i++)

result=result+A;

printf("%d*%d=%d\n",a,b,result);

}

Is SQL a high level language?

Yes, SQL is a high level language, since it allow us to get result without much going into Assembly level instructions, by using interpreter to change our statements/queries into machine level instructions!.

What are the words that make up a high-level programming language called?

Some languages have specific terms, however keyword or reserved word is the general terminology we use when referring to a programming language's primary vocabulary. That is; words that cannot be used as identifiers. However, some languages also have contextual keywords. For instance, C++ has final and override contextual keywords. These can be used as both identifiers and keywords, depending on the context. The only reason for this is that people were using these words as identifiers before they were introduced to the language (in C++11) and making them actual keywords would have broken a lot of older code.

How to run C graphics program?

"http://wiki.answers.com/Q/How_to_run_C_graphics_program"

What is the difference between prefix and postfix increment operator in c plus plus?

Both the prefix and the postfix increment operators increment the operand. The difference is what is the value of the expression during the evaluation of the expression. In the prefix form, the value is already incremented. In the postfix form, it is not.

int a = 1;

int b = ++a;

// both a and b are now equal to 2

int a = 1;

int b = a++;

// a is equal to 2 and b is equal to 1

How to write a C program to generate Fibonacci series up to 10 elements and store in array?

#include <iostream.h>

#include <conio.h>

#include <stdlib.h>

int swap(int* , int*);

int main()

{

int c=0;

int b=1;

int max;

cout<<"Enter the maximum limit of fibbonacci series = ";

cin>>max;

if(max>0)

{

cout<<c<<endl;

}

else

{

exit (EXIT_FAILURE);

}

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

{

c=b+c;

swap(&b,&c);

if(c<max)

{

cout<<c<<endl;

}

else

{

break;

}

}

getch();

return 0;

}

int swap(int *x,int *y)

{

int z;

z=*x;

*x=*y;

*y=z;

return z;

}

How to Convert binary to decimal in c?

#include<stdio.h>

#include<conio.h>

void main()

{

int i,n,k,j,b[100];

clrscr();

printf("Enter a Number:");

scanf("%d",&n);

k=n;

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

{

b[i]=n%2;

n=n/2;

if(n==0)break;

}

printf("\n\nBinary Equivalent:");

for(j=i;j>=0;j--)

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

getch();

}

Happy Coding...!!!

What do you mean by string in c language?

Character arrays or pointers to character are termed as strings in c language. Like:

char arr[10] = {'s', 't', 'i', 'n', 'g'};

char *pchar = "string";

Above answer is the first answer for the question

But there is a lot of difference between character array and string.

string means a group of characters .And string is enclosed between double quotation marks i.e(" ") .

Declaration of string is same as of char array ,which is as follows

char str[20];

And initialization is different from that of character array

initialization:-

char str[7]={"vardhan"};

Write a program to print binary equivalent of given integer value in c?

Inorder to display a binary value of a number in C language, 1st create an integer array of size n. Then inside a for loop divide that number by 2 repeatedly and store the remainder in that array from 0 to n. The remainder is always a 0 or 1. Finally when the number itself reaches 1, put this 1 also in your array. Then display it by printing the array from n-1 to 0.

What program do they use to make c plus plus compilers?

The first generation C++ compiler was written in C. Newer generations of C++ compilers are written using the previous generation of C++, however some implementations also use assembler, either in part or in whole.

Bear in mind that one of the first programs ever written for a computer was an assembler. Before assembler, all code had to be written in machine code, the native language of the computer, which was labour intensive and prone to error. But that was exactly how the first generation assembler had to be written. Thereafter, the assembler was used to create the next generation assembler, and the next, until high-level languages began to appear (again, written in assembler), until C finally appeared, which eventually led to C++.

Which translates c source code into object code before the program can be executed?

Question #1: Compiler.

Question #2: If you want to execute an external program in C, use function system.
A translator in computer programming is a piece of software that translates one programming language to another.

Therefore a C translator would translate either C source code into another language, let's say BASIC.

So if you had a C to BASIC translator, you would write a program in C and the translator would give you the equivalent source code in BASIC.

I have never used a translator, but at first glance, it doesn't sound very reliable for both security and memory management reasons.

In C programming a character variable can at a time store how many characters?

You can store one, however if you make a char array:

char[50];

You can make a string out of your array of characters.

Write a program to print n natural numbers using do-while loop?

//(this is just a function, call this as count(n) in your main loop)

void count(int n){

int i = 1;

do{

printf("%d", i);

i++;

} while(i<=n);

}

Write a vb program to find the simple interest?

n1=val(text1.text)

n2=val(text2.text)

n3=val(text3.text)

text4.text=(n1*n2*n3)/100

Advantage of flowchart in c language?

Pre-test loop in C#

bool condition = false; [NOTE: this line is not part of the loop it is the condition which must be met for the loop to occur. If it is not satisfied the loop does not happen.

while (condition == false)
{
Do stuff
condition = checkCondition();
}

To draw this as a flowchart you just have to show that your flowchart can repeat a step/steps indefinitely depending on a condition

What is the Decision Tree?

Decision trees are used mainly in the business world to help strategize many business investments and planning. It would include things such as possible outcomes, costs, etc.

How to write algorithm in c program?

Algorithms are created using pseudocode, which is a combination of natural language (such as English) and commonly understood programming concepts. Pseudocode is a machine-independent language, but it is far too abstract for a machine to understand. It is intended for humans only. As programmers, our job is to translate these algorithms into a form the machine can process in order to produce the required machine-dependent code. For this we use programming languages, such as C, C++ and Java.

The more abstract the programming language, the easier it is to convert an algorithm into working code. Of all the high-level programming languages, C has the least amount of abstraction, however we can make use of third party libraries to increase the amount of abstraction, or we can use the language itself to create our own abstractions.

Write a C program for Sum of factors of a number?

#include<stdio.h>

#include<conio.h>

void factor(int num)

{

int i,sum=0;

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

{

if(num%i==0)

{

sum=sum+i;

}

}

printf("Sum of the factor of %d is %d",num,sum);

}

void main()

{ int num;

printf("Enter the number=");

scanf("%d",&num);

factor(num);

getch();

}

Why should you let inoculating loop cool first before using?

an innoculated loop shouln't be hot. it should be cooled before contact with the organism by touching it off the edge of the agar or dipped into the top of the broth. if its hot it will kill the organism!

How do you write a program to compute and print the factorial of given number using a while loop in c plus plus?

// returns n!

int fact(final int n) {

// keep track of factorial calculation in f

// f starts at n, and we will multiply it by all integers less than n

int f = n;

// loop from n-1 down to 2

for(int i = (n - 1); i > 1; --i) {

// increase our total product

f *= i;

}

return f;

}

Program to check the presence of a substring in a given string?

#include<stdio.h>

#include<string.h>

main()

{

char a[24];

int i,count=0,j=0,stlen,k,substlen,sig=0;

gets(a);

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

{if(a[i]==' ')

break;

else j++;}

stlen=j;

substlen=strlen(a)-j-1;

for(i=0;i<=stlen-substlen;i++)

{count=0;

for(k=i+substlen-1;k>=i;k--)

{if(a[k]!=a[k+stlen-i+1])

break;

else count++;}

if(count==substlen)

{sig=1;

break;

}

}

printf("%d",sig);

}

input-

11100101 1001

110010 111

output-

1

0

note -give the main string and the substring(to be checked) seperated by a space.

C program to find the occurrence of an element in a number?

Let "n" is that number and "occ" is the no of occurrence of a element "el" in "n".

so,

<pre>

i = n;

occ = 0; // Initializing "occ" to zero.

while(i > 0){

rem = i % 10; // This gives a digit in the number.

if(rem == el) occ++; // If "rem" is same as "el" then increament "occ".

i = i / 10; //By this we are extracting rem from number i.

}

printf("No of Occurrence of %d element is : %d", el, occ); // Printing the number of occurences

</pre>

that's it.