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

How can you get how much memory is available using c program?

You don't say whether you mean physical memory or virtual memory. Regardless, there is no portable method given that memory management is system-specific. However, the system should provide some means of giving you the information you need. The following example works on Windows and Linux:

#ifdef WIN32 #include <windows.h>

unsigned long long getTotalSystemMemory()

{

MEMORYSTATUSEX status;

status.dwLength = sizeof(status);

GlobalMemoryStatusEx(&status);

return status.ullTotalPhys;

}

#else // UNIX...

#include <unistd.h>

unsigned long long getTotalSystemMemory()

{

long pages = sysconf(_SC_PHYS_PAGES);

long page_size = sysconf(_SC_PAGE_SIZE);

return pages * page_size;

}

#endif

What two steps are needed to create an array?

For example we have a class :

public class Test()

{

public void print()

{

System.out.println("Hello");

}

}

So, if you want to create array from Test type. You can try something like this :

Test[]myTestArray=new Test[2];

myTestArray[0]=new Test();

myTestArray[1]=new Test();

I hope it will help.

Draw a flowchart to find the sum of given n positive numbers in c?

  1. draw terminal symbol
  2. draw I/O symbol (parallelogram) to get array elements in a variable (e)
  3. draw process symbol (rectangle) to define array. e.g ary(e)
  4. draw decision box to check number of iterations (i<=e)
  5. if condition is true then take input in array (ary(i))
  6. take variable to sum each element of array:(s=s+ary(i))
  7. go to step 4
  8. if given condition in step 4 becomes false then print variable a, containing sum
  9. end up the flowchart

What is the flowchart C program to check wether a given character is vowel or not using switch case?

Switch case can be flowcharted using a diamond for each case, with a right branch for true and a down branch for false. The false branch simply connects to the next case. The true branch connects to the statement that should be executed for that case. Where multiple cases result in the same statement, the true branches should converge upon that statement. The execution path from the statement(s) should converge with the final false branch of the switch case.

In this case, your switch case might be as as follows:

print %letter%

switch lowercase (%letter%)

{

case 'a':

case 'e':

case 'i':

case 'o':

case 'u':

print line " is vowel"

break;

default:

print line " is not vowel"

}

Thus you will have a column of diamonds for each case with false branches linking downwards from one diamond to the next. The statement for case 'a', 'e', 'i', 'o' and 'u' is the same, so their true branches (extending to the right) will converge upon the 'print line " is vowel"' statement which must be placed to the right of the case diamonds. The default case's true branch leads to the 'print line " is not vowel"' statement. Both these statements will then converge with the false branch from the default case, marking the end of the switch case.

Note that, logically, there is no false branch from a default case, thus this link may be omitted. However, all links from all statements must still converge below the default case.

Are there different types of skateboards?

Yes there are good brands of boards such as element, baker, birdhouse, active and DVS.

Definition of Identifier in C Language?

Identifiers or symbols are the names you supply for variables,type,function and labels.Identifiers names must differ in spelling and case from any keyword.you cannot use keyword as an identifier.you can create an identifier by specifying it in the declaration of a variable,type or function.

7 Write a program to append one file at the end of another?

#include

#include

void main()

{

FILE *fp1,*fp2;

char ch,fname1[20],fname2[20];

printf("\n enter sourse file name");

gets(fname1);

printf("\n enter sourse file name");

gets(fname2);

fp1=fopen(fname1,"r");

fp2=fopen(fname2,"a");

if(fp1==NULLfp2==NULL)

{

printf("unable to open");

exit(0);

}

do

{

ch=fgetc(fp1);

fputc(ch,fp2);

}

while(ch!=EOF);

fcloseall();

}

Write an algorithm and Draw a flowchart to accept two numbers and display the sum of the numbers?

#include

using std::cout;

using std::cin;

using std::endl;

int main()

{

double firstNumber = 0;

cout << "Enter first number: ";

cin >> firstNumber;

double secondNumber =0;

cout << "Enter second number: ";

cin << secondNumber;

cout << "Sum of the two numbers is: " << (firstNumber + secondNumber) << endl;

return 0;

}

What is The statements written by the programmer?

In languages that use a C-style syntax (e.g., C, C++ and Java) all code is written using expressions. Expressions may be combined to produce more complex expressions, however an expression or group of expressions only becomes a statement when terminated by a semi-colon. A group of statements enclosed by braces {} is known as a compound statement or code block.

Write a program to obtain transpose of a 4 X 4 Matrix in c using functions?

void main()

{

int arr[4][4];

int i,j,a,b,f;

printf("\nInput numbers to 4*4 matrix");

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

{

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

{

printf("\nKey in the [%d][%d]) value",i+1,j+1);

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

}

}

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

{

for(j=0,f=0;j<4;j++)

{

if(i!=j&&f==0)

continue;

a=arr[i][j];

b=arr[j][i];

arr[i][j]=b;

arr[j][i]=a;

f=1;

}

}

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

{

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

printf("%d ",arr[j][i]);

printf("\n");

}

}

Why is it easier to convert numbers from binary to hexadecimal than decimal to hexadecimal?

A binary number system has two states '0' '1' for a long word in bits it can be as follows 101010101010101010101011 intimidating RIGHT? it can be represented in groups of 3 bits in octal 10/010/101/010/101/010/101/011= 22525253 digital or in group of 4 bits as 10/1010/1010/1010/1010/1010 = 2AAAAA

111 =7 octal 1111=f F in hexadecimal numbers 1000 =8 1010 =10 or A

WRITE A Program to convert integar to hexadecimal in c language?

Use the %X modifier of printf.

Code Example:#include int main(void) { unsigned int iMyNumber = 255; printf("The number %u interpreted as hexadecimal is %X.\n", iMyNumber, iMyNumber); return 0; }

How many types of parameters passing techniques are there In c language?

There are only two methods: pass by value and pass by reference. The function itself determines how arguments are passed into the function, as defined by the function signature. If the function accepts a reference, then the argument is passed by reference, otherwise it is passed by value. Pointers are always passed by value but behave like references. The only real difference is that pointer values may be NULL but references can never be NULL.

How do you make C plus plus Program Autorun?

This is not a C++ question. It is an operating system question. Different operating systems have different ways of making programs run on startup. Most of them have several different ways to accomplish this. In MS Windows, one way is to place a shortcut for the program in the "{percent}userprofile{percent}\Start Menu\Programs\Startup" shell folder.

What is a useful way of finding the value of a variable?

Reading a table, drawing a graph, drawing a diagram, and writing a equation.

Why are computer languages used for problem solving?

A programming language is a systematic notation by which we describe computational process. Computational process means steps for solving a problem.

Understanding of computer software is imperfect without a basic knowledge of programming language. Programming language allow the programmers and end users to develop the programs that are executed by a computer. In today's world several computer languages exist. Some of these are created to serve a special purpose (like controlling a robot), while others are more flexible. General purpose tools that are suitable for many types of applications.

However, every computer language must have instructions that fall into following categories like:

1. Input/Output

2. Calculations/Text Manipulation

3. Logic/Comparison

4. Storage/Retrieval

What are syntax rules?

Syntax is the discipline that examines the rules of a language that dictate how the various parts of sentences go together. While morphology looks at how the smallest linguistic unit (called morphemes) are formed into complete words, syntax looks at how those words are formed into complete sentences. Syntax is not prescriptivist - which is to say, it does not attempt to tell people what the objectively correct way to form a sentence is. Rather, it is descriptivist, in that it looks at how language is actually used and tries to come up with rules that successfully describe what various language communities consider to be grammatical or non-grammatical. Syntax deals with a number of things, all of which help to facilitate being understood and understanding language. Without rules of syntax, there would be no foundation from which to try to discern meaning from a bunch of words strung together, whereas with syntax, an infinite number of sentences are possible using a fairly small finite number of rules.
to put it simply syntax is the arrangement of words in a sentence or paragraph ect...

but the exact dictionary definition is:the study of the patterns of formation of sentences and phrases from words.


Syntax is the general rule that humans have to abide by which is that the composition of a coherent sentence using grammar and structure must be cognitively structured in the mind of someone's brain before they can communicate it to a receiver through means of making a series of small mouth noises. Syntax is the arrangement of words and phrases to create a message in a language.

Write the algorithm to find the largest number of three number?

To determine the largest of any group of numbers, we must first determine the largest of any two numbers. For that we use the following simple algorithm:


If number A is greater than number B, then return number A otherwise return number B.


In C++ we can encode this algorithm using the following template function: