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

Write a c program to desine simple calculator using switch case?

// Addition Of Two Numbers Which r Taken From User!

/*Program Written by Maulin Thaker Ahmedabad;*/

#include

#include

void main()

{

float n1,n2,ans;

printf("Enter the First number\n");

scanf("%f",&n1);

printf("Enter the Second number\n");

scanf("%f",&n2);

ans=n1 + n2;

printf("Your Answer is -: %.3f",&ans);

}

What is structured assemly language programming and C programming?

A way of writing computer programs that are human readable (and understandable to programmers).

Write a algorithm in c to add two sparse matrices?

#include <stdio.h>

#include <conio.h>

#include <alloc.h>

#define MAX1 3

#define MAX2 3

#define MAXSIZE 9

#define BIGNUM 100

struct sparse

{

int *sp ;

int row ;

int *result ;

} ;

void initsparse ( struct sparse * ) ;

void create_array ( struct sparse * ) ;

int count ( struct sparse ) ;

void display ( struct sparse ) ;

void create_tuple ( struct sparse *, struct sparse ) ;

void display_tuple ( struct sparse ) ;

void addmat ( struct sparse *, struct sparse, struct sparse ) ;

void display_result ( struct sparse ) ;

void delsparse ( struct sparse * ) ;

void main( )

{

struct sparse s[5] ;

int i ;

clrscr( ) ;

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

initsparse ( &s[i] ) ;

create_array ( &s[0] ) ;

create_tuple ( &s[1], s[0] ) ;

display_tuple ( s[1] ) ;

create_array ( &s[2] ) ;

create_tuple ( &s[3], s[2] ) ;

display_tuple ( s[3] ) ;

addmat ( &s[4], s[1], s[3] ) ;

printf ( "\nResult of addition of two matrices: " ) ;

display_result ( s[4] ) ;

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

delsparse ( &s[i] ) ;

getch( ) ;

}

/* initialises structure elements */

void initsparse ( struct sparse *p )

{

p -> sp = NULL ;

p -> result = NULL ;

}

/* dynamically creates the matrix */

void create_array ( struct sparse *p )

{

int n, i ;

/* allocate memory */

p -> sp = ( int * ) malloc ( MAX1 * MAX2 * sizeof ( int ) ) ;

/* add elements to the array */

for ( i = 0 ; i < MAX1 * MAX2 ; i++ )

{

printf ( "Enter element no. %d:", i ) ;

scanf ( "%d", &n ) ;

* ( p -> sp + i ) = n ;

}

}

/* displays the contents of the matrix */

void display ( struct sparse s )

{

int i ;

/* traverses the entire matrix */

for ( i = 0 ; i < MAX1 * MAX2 ; i++ )

{

/* positions the cursor to the new line for every new row */

if ( i % MAX2 0 )

printf ( "\n" ) ;

printf ( "%d\t", * ( s.result + i ) ) ;

}

}

/* deallocates memory */

void delsparse ( struct sparse *p )

{

if ( p -> sp != NULL )

free ( p -> sp ) ;

if ( p -> result != NULL )

free ( p -> result ) ;

}

What is the difference between linear and circular queue?

What is the difference between linear and circular queue? In: http://wiki.answers.com/Q/FAQ/2545-37 [Edit categories]


The Queue by Default is Linear, it would be termed as Circular if the Last Element of the Queue pointsto the first element of the List

How convert integer to float using switch case in c?

The switch/case statement in the c language is defined by the language specification to use an int value, so you can not use a float value. You can, however, convert the float into an int and use it, so long as the resulting values and functionality meet your functional requirements.

Write algorithm and draw a flow chart to find the total and average of a student for six subjects?

write an algorithm to compute the weekly average rainfall given the daily rainfall for four weeks

Why assembly language is still needed if you have hll offering sophisicated tools?

Yes, assembly language is definitely still used. Many I/O drivers and much of the bootstrap code that starts a computer must be written in assembly language as high level languages do not provide means for coding certain special purpose instructions needed for these operations. Also high level languages usually require that subroutine library codes be available, while assembly language does not. As these subroutine library codes usually cannot be loaded until the Operating System is up and running, assembly language must be used for much of the code that bootstraps the computer and loads the Operating System.

Who are stack holders?

Different parties have a stake in the quality of the outcome and the impact of changesrelated to an Organization.

Define structure oriented programming language?

A structure oriented language is one, which should the following structure as Documentation Section, Link section, Definition Section, Global declaration section and Functions(including Main functions) in an hierarchical order. This order cannot be interchanged, but structure oriented language like C can have these sections as optional. Correct me if am wrong, Neela.T

How do you write c program to find sum of two numbers?

For example:

c = a + b;

(This calculates the sum of a + b, and assigns the result to variable c.)

If you repeatedly want to add something to an accumulated sum:

b = b + a;

or better:

b += a;

For example:

c = a + b;

(This calculates the sum of a + b, and assigns the result to variable c.)

If you repeatedly want to add something to an accumulated sum:

b = b + a;

or better:

b += a;

For example:

c = a + b;

(This calculates the sum of a + b, and assigns the result to variable c.)

If you repeatedly want to add something to an accumulated sum:

b = b + a;

or better:

b += a;

For example:

c = a + b;

(This calculates the sum of a + b, and assigns the result to variable c.)

If you repeatedly want to add something to an accumulated sum:

b = b + a;

or better:

b += a;

How can loops be used to process arrays?

Loops can be used to iterate or walk through an array. For example, suppose you have an array already initialized (we'll call it "array"):

int target = -1;

for (i=0; i < array.length(); i++){

if (array[i] = target){

//do something

}

}

Here, we will walk through an array (note that arrays are zero indexed) using a loop to make sure we hit each element of the array. In our loop, we start at the head (or first element) and iterate over each element.

What is strongly typed programming language?

Yes, Python is strongly-typed.

You can test if any language is strongly-typed with a very simple example:

x = 1

y = "2"

z = x + y

The above will not compile in a strongly typed language because y is a string, not a number. That is, the language will not implicitly convert y to a number simply because you used it in a numeric expression. A weakly-linked language will perform the conversion behind the scenes.

Note that some strongly typed languages will permit the following:

value = 1

value = "one"

This is an example of dynamic typing; the same variable has explicitly changed type. This is not possible with statically typed languages. However, dynamic typing does not imply weak typing. Dynamic typing is explicit, weak typing is not.

C code programming to reverse a number?

/*The coding style used in this source code is for convenience.

* It is widely used style of coding. */

#include <stdio.h>

void main() {

int number, modulus, reverse;

reverse = 0;

printf("Enter a number \n");

scanf("%d", &number);

while(number != 0) {

modulus = number % 10;

reverse = (reverse * 10) + modulus;

number =number / 10;

}

printf("The reversed number is %d", reverse);

getch();

}

C program without main functoin?

If we save our program with .c extention before compiling it, the compiler with automatically include the header files. for eg-

First we save our program with sum.c and then compile it. It will not show any error.

1. Compilation needs header files, not execution.

2. Very small example programs can be written without using any header file, eg:

/* mini.c */

extern void (const char *puts);

int main (void)

{

puts ("Hello, world");

return 0;

}

What are the rules for naming an array?

The same rules apply to naming arrays as for naming any other identifier (be it a user-defined data type, variables or constants and function names). All identifiers must begin with a non-digit character (see below) and must be unambiguous. Global or external identifiers may be subject to additional restrictions as they have to be processed by other software such as linkers.

Non-digit characters:

_ a b c d e f g h i j k l m n o p q r s t u v w x y z

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

How can you add different type of data in a stack?

stack is a linear data structure in which data item is either inserted or deleted at one end there are mainly two operations performed on stack.they're push poppush:writing a value to the stack is push or moving the stack pointer up to accomodatethe new item. pop:reading a value from stack or moving the stack pointer down.

Factorial of a number using recursion?

#include<stdio.h>

main()

{

int a;

printf("Enter a");

scanf("%d",&a);

a=fun(a);

printf("%d",a);

}

int fun(int x)

{

if(x==1)

{

return 1;

}

else

{

x=x*fun(x-1);

}

return x;

}

What do you mean by derived data type in java?

A data type of an object describes the kind of information stored in that object. Numbers, strings, images, and all other information in a program is described by some sort of data type.

What are the different structures of programming?

Kinds of programming language construct : * block (1 kind, 2 facts) * class (15 kinds, 28 facts) - A software module that provides both procedural and data abstraction. It describes a set of similar objects, called its instances * comment (1 kind, 12 facts) * condition (3 kinds, 2 facts) * data item (2 kinds, 2 facts) * data type (1 kind, 3 facts) * declaration (1 kind, 2 facts) * exception (2 kinds, 5 facts) - A situation that arises in a program requiring special handling, and hence deviation from the normal path of control * function (1 kind, 2 facts) * keyword (1 kind, 2 facts) * name space (1 kind, 2 facts) * operator (1 kind, 2 facts) * package^2 (1 kind, 5 facts) - A facility for grouping a set of classes * procedure (2 kinds, 3 facts) * statement (10 kinds, 3 facts) Source: http://www.site.uottawa.ca:4321/oose/index.html#programminglanguageconstruct

Abap Program To find Factorial of number?

report zbharath.

data:num type i value 5,

fac type i value 0.

perform fact using num changing fac.

write:/ 'factorial of',num,'is',fac.

form fact.

using value(f-num) type i.

changing f-fact type i.

f-fact=1.

while f-num ge 1.

f-fact=f-fact*f-num.

f-num=f-num-1.

endwhile.

endform.

What is semi structured decision?

one in which the being who decides it does not have a realistic plan for maintaining/ achieving the object if decision

Is compiler a hardware?

Programming language compilers are application programs. In some publications, however, the term system software also includes software development tools (like a compiler, linker or debugger).

Is it possible to declare a variable in a method and use it in a main?

Yes you can and they are known as inner methods. You can even delcare an inner class and methods on it. However, if you want your classess accessible from multiple programs (reusability), then you should not use this practice. This type of facility is useful when you know for sure that your class or method is going to be used only once.