C Language

C Language

+ Follow 25,616 Followers

Showing 51 to 75 of 178
Sort By: 
D

Dhanya 15/07/2016 in  C Language Classes

Show previous answers

Sundeep replied | 29/07/2016

int main()
{
printf("%f",ceil(1.66));
}
Add header files stdio.h and math.h
stdio.h for printf
math.h for ceil.

0 0

Dishaapro replied | 04/08/2016

Thanks for the question Dhanya ......
Using the function ceil (1.66)
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Answer

You can add upto 6 Images

B

Basundhara 15/07/2016 in  C Language Classes

Show previous answers

Surya Narayana replied | 08/08/2016

Yes, every operator will have an associativity.

0 0

Pinal Pathak replied | 09/08/2016

Yes every operator has an associativity which decides the priority to calculate any expression. lets say if you have expression like 5*6+3-2 ..so which to operate first. * has higher associativity then + and - so it has to be evaluated first

0 0

Answer

You can add upto 6 Images

R

Rakhi 15/07/2016 in  C Language Classes

Show previous answers

Kumar replied | 02/08/2016

Statements which are enclosed in left brace ({) and the right brace (}) forms a local Block.
Local Block can have any number of statements.
Branching Statements or Conditional Statements, Loop Control Statements such as if,else,switch,for,while forms a local block.
These Statements contain braces , so the portion of code between two braces would be considered a local...  more»
Statements which are enclosed in left brace ({) and the right brace (}) forms a local Block.
Local Block can have any number of statements.
Branching Statements or Conditional Statements, Loop Control Statements such as if,else,switch,for,while forms a local block.
These Statements contain braces , so the portion of code between two braces would be considered a local block.
Variables declared in a local block have local scope i.e they can be accessed within the block only. «less

0 0

Dishaapro replied | 04/08/2016

Thanks for the question Rakhi,
The portion of code within two braces of a function is known as local block.
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Answer

You can add upto 6 Images

D

Deepak 15/07/2016 in  C Language Classes

Show previous answers

Sg replied | 07/08/2016

Questionable:
Efficient in speed, store as int,
Efficient in memory consumption then use Bit Fields.

Team http://www.SG-Tech.in

0 0

Ravikant replied | 13/08/2016

use the int flag =0 ; and later on inside some while() loop if some condition you got set flag =1 and return

0 0

Answer

You can add upto 6 Images

K

Kiran 15/07/2016 in  C Language Classes

Show previous answers

Rahul P replied | 04/08/2016

Bit masking means selecting only certain bits from byte(s) that might have many bits set. To examine some
bits of a byte, the byte is bitwise “ANDed” with a mask that is a number consisting of only those bits of interest.

0 0

Sourabh replied | 04/08/2016

"bit masking" means multiply the number by a matrix of bits.

0 0

Answer

You can add upto 6 Images

N

Nadare 15/07/2016 in  C Language Classes

Show previous answers

Maqubool replied | 22/07/2016

Bitshift will increase time complexity in comparison with to multiply by 2. As usually the literals are represented by at least 8 bits (ASCII). Therefore, at least 8 iterations will perform one task which is far more than multiplication statement.

0 0

Umang replied | 02/08/2016

Yes, bitshift is faster than multiplication and division which follows algorithm that is booth's multiplication.

0 0

Answer

You can add upto 6 Images

A

Akhilesh 15/07/2016 in  C Language Classes

Show previous answers

Ravikant replied | 08/08/2016

Programmers can disable using some flag

0 0

Techtok replied | 09/08/2016

Commenting.

// This line is a comment and will not be read by the compiler

/* These lines are
comments
and
will not be read
by the
compiler */

0 0

Answer

You can add upto 6 Images

T

Thileshwari 15/07/2016 in  C Language Classes

Show previous answers

Maqubool replied | 22/07/2016

Header files are included only at compile time. So yes we can define which header file you want to include. Although, you cannot use them as a program statement as they're preprosessive.

0 0

Dishaapro replied | 04/08/2016

Thanks for the question......
Yes you can define it with the help of #if, #else and #endif pre-processor directive.
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Answer

You can add upto 6 Images

S

Sivaganesh 15/07/2016 in  C Language Classes

Show previous answers

Rahul P replied | 04/08/2016

An array tag is not something you can put on the left side of an assignment operator.An array is an object; the array tag is a pointer to the first element in that object.

0 0

Dishaapro replied | 04/08/2016

Thank You for the question Sivaganesh,
No because an array tag is a constant value known at link time.
Thank You,
Team DishaaPro
http://www.dishaapro.com

0 0

Answer

You can add upto 6 Images

V

Vijay 15/07/2016 in  C Language Classes

Show previous answers

Sourabh replied | 04/08/2016

No.

0 0

Dishaapro replied | 04/08/2016

Thank You for the question Vijay,
Yes you can force stdout to be printed somewhere other than the screen by using the concept redirection.
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Answer

You can add upto 6 Images

N

Neelima 15/07/2016 in  C Language Classes

Show previous answers

Ganesa replied | 08/08/2016

use stat() function, that will show you file's attributes..

0 0

Anamika Sawhney replied | 08/08/2016

The C date and time operations are defined in the time.h header file
time_t current_time;
char* c_time_string;

/* Obtain current time. */
current_time = time(NULL);

0 0

Answer

You can add upto 6 Images

M

Moid 15/07/2016 in  C Language Classes

Is it true that a global variable may have several declarations, but only one definition?

0 0 4

Show previous answers

Maqubool replied | 22/07/2016

For automatic and register variables, there is no difference between definition and declaration. The process of declaring an automatic or a register variable defines the variable name and allocates appropriate memory. However, for external variables, these two operations may occur independently.

0 0

Dishaapro replied | 04/08/2016

Thanks for the question Moid ......
Yes variables can be declared more than once if it is declared globally by using extern keyword.
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Answer

You can add upto 6 Images

R

Rajinder 15/07/2016 in  C Language Classes

What are different between declaration & definition?

0 0 4

Show previous answers

Umang replied | 02/08/2016

Declaration tells the compiler the presence of a variable named so and so in the program.
Definition assigns the memory address to the variable.
The best example of declaration and definition is:
struct var
{
int a;
char b;
};
This is only declaration because no object is created of var type.
Whereas, If we do int x; in main() function,...  more»
Declaration tells the compiler the presence of a variable named so and so in the program.
Definition assigns the memory address to the variable.
The best example of declaration and definition is:
struct var
{
int a;
char b;
};
This is only declaration because no object is created of var type.
Whereas, If we do int x; in main() function, then it is declaration and definition as well because compiler gets to know about x and memory location is also assigned to x. «less

0 0

Dishaapro replied | 04/08/2016

Thanks for the question Rajinder......
Declaring a variable means to inform the compiler that the variable is declared of this data type. Variable definition means to ask the compiler for memory.

Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Answer

You can add upto 6 Images

S

Shagufta 15/07/2016 in  C Language Classes

When we mention the prototype of a function?

0 0 3

Show previous answers

Dishaapro replied | 04/08/2016

Thanks for the question Shagufta,
We can mention the prototype of a function in both declaration or definition.
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Surya Narayana replied | 07/08/2016

We mention prototype of a function at the beginning of the program soon after the inclusion of header files. First comes header files and next to them we write prototype of a function

0 0

Answer

You can add upto 6 Images

A

Atharva 15/07/2016 in  C Language Classes

Will the expression *p = p be disallowed by the compiler?

0 0 3

Show previous answers

Dishaapro replied | 04/08/2016

Thanks for the question Atharva,
No because even though the value of p is accessed twice it is used to modify two different objects p and *p.
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Sg replied | 09/08/2016

Compiler should disallow or at the least warn you,
As no types were mentioned and given you are de-referencing using *p so presuming p is a pointer,
For sake of simplicity, presume p is of type int* ie:
int *p;

then in statement below, lhs is of type int and rhs is of type int*, you shouldn't assign int* to an int.
*p = p

If you really...  more»
Compiler should disallow or at the least warn you,
As no types were mentioned and given you are de-referencing using *p so presuming p is a pointer,
For sake of simplicity, presume p is of type int* ie:
int *p;

then in statement below, lhs is of type int and rhs is of type int*, you shouldn't assign int* to an int.
*p = p

If you really want to do that (hope you understand what you are doing with your memory), then you should force typecast it to (int*), so that compiler doesn't generate a warning.

Team http://www.SG-Tech.in «less

0 0

Answer

You can add upto 6 Images

S

Sensoph 15/07/2016 in  C Language Classes

Which keyword used to transfer control from a function back to the calling function?

0 0 4

Show previous answers

Dishaapro replied | 04/08/2016

Thanks for the question Sensoph,
return keyword is used to transfer control from a function back to the calling function.
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Surya Narayana replied | 08/08/2016

'return' keyword is used to transfer control

0 0

Answer

You can add upto 6 Images

B

Benjamin 15/07/2016 in  C Language Classes

How can you tell if a loop ended prematurely?

0 0 4

Show previous answers

Manvendra Singh replied | 05/08/2016

Generally, loops are dependent on one or more variables. Your program can check those variables outside
the loop to ensure that the loop executed properly. For instance, consider the following example:

#define REQUESTED_BLOCKS 512
int x;
char* cp[REQUESTED_BLOCKS];
/* Attempt (in vain, I must add...) to allocate 512 10KB blocks in memory. */
...  more»
Generally, loops are dependent on one or more variables. Your program can check those variables outside
the loop to ensure that the loop executed properly. For instance, consider the following example:

#define REQUESTED_BLOCKS 512
int x;
char* cp[REQUESTED_BLOCKS];
/* Attempt (in vain, I must add...) to allocate 512 10KB blocks in memory. */
for (x=0; x< REQUESTED_BLOCKS; x++)
{
cp[x] = (char*) malloc(10000, 1);
if (cp[x] == (char*) NULL)
break;
}
/* If x is less than REQUESTED_BLOCKS, the loop has ended prematurely. */
if (x < REQUESTED_BLOCKS)
printf(“Bummer! My loop ended prematurely!
”);

Notice that for the loop to execute successfully, it would have had to iterate through 512 times. Immediately
following the loop, this condition is tested to see whether the loop ended prematurely. If the variable x is
anything less than 512, some error has occurred. «less

0 0

Chetan replied | 11/08/2016

If we check the loop variable we can check whether the loop is terminated or completed.

0 0

Answer

You can add upto 6 Images

N

Nasar 15/07/2016 in  C Language Classes

Are bit fields portable?

0 0 4

Show previous answers

Manvendra Singh replied | 05/08/2016

Bitfields are not quite as portable as you think, as "C gives no guarantee of the ordering of fields within machine words"

Ignoring that, used correctly, either method is safe. Both methods also allow symbolic access to integral variables. You can argue that the bitfield method is easier to write, but it also means more code to review.

0 0

Chetan replied | 11/08/2016

Yes, This makes the representation compiler-independent. i.e. they are portable, but what they do may not necessarily be exactly what a person actually wanting to manipulate individual bits may need. Bit fields are standard language feature. They will compile in all C compilers.

0 0

Answer

You can add upto 6 Images

A

Archit 15/07/2016 in  C Language Classes

How are 16- and 32-bit numbers stored?

0 0 4

Show previous answers

Chetan replied | 11/08/2016

A 16-bit number takes two bytes of storage, a most significant byte and a least significant byte.
A 32-bit number takes four bytes of storage

0 0

Praveen replied | 12/08/2016

Numbers like int, long are stored in 2's complement format in memory and the memory is organized using little endian format. And the decimal numbers like float, double are stored using IEEE 754 floating point representation. For more details, contact me on: NineFiveFourZeroEightOneFiveTwoSevenEight

0 0

Answer

You can add upto 6 Images

S

Subhradeep 15/07/2016 in  C Language Classes

What will the preprocessor do for a program?

0 0 3

Show previous answers

Rahul P replied | 04/08/2016

The preprocessor takes a look at your source code just before it goes off to the compiler, does a little formatting, and carries out any instructions you have ... to preprocessor is used for including and defining a header file

0 0

Dishaapro replied | 04/08/2016

Thank You for the Question Subhradeep......
The pre-processor directive is a statement that gives the pre-processor specific instructions on how to modify the source code. It always runs automatically by the compiler.
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Answer

You can add upto 6 Images

G

Govind 15/07/2016 in  C Language Classes

What is the benefit of using #define to declare a constant?

0 0 4

Show previous answers

Sourabh replied | 04/08/2016

It becomes a global variable. You can use it main and in any function in the file.

0 0

Dishaapro replied | 04/08/2016

Thanks for the question Govind ......
The constant which have defined using #define function can be used anywhere in the program without re declaration
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Answer

You can add upto 6 Images

T

Tania 15/07/2016 in  C Language Classes

Is it better to use a macro or a function?

0 0 4

Show previous answers

Umesh replied | 05/08/2016

Macro is gud for short program but function is good for long program..because macro expand which increase the size of running program.but function use switching address mechanism..

0 0

Ravikant replied | 13/08/2016

Normally macro is of one or two line. it takes less time compare to function execution. But if number of line of code is more you can use function

0 0

Answer

You can add upto 6 Images

A

Anitha 15/07/2016 in  C Language Classes

How many levels deep can include files be nested?

0 0 3

Show previous answers

Harish replied | 04/08/2016

Even though there is no limit to the number of levels of nested include files you can have, your compiler might run out of stack space while trying to include an inordinately high number of files. This number varies according to your hardware configuration and possibly your compiler.

0 0

Dishaapro replied | 04/08/2016

Thanks for the question Anitha ......
It depends on the compiler. By default they may be nested up to the depth of at least 8.
Thanks,
Team DishaaPro
http://www.dishaapro.com

0 0

Answer

You can add upto 6 Images

P

Prasenjit 15/07/2016 in  C Language Classes

How can type-insensitive macros be created?

0 0 4

Show previous answers

Punit replied | 11/08/2016

Similar to polymorphism in c++ if you are familiar to this.
A type insensitive macro is a macro that perform the same base operation on different data type.Have common name but different signature. This task can be accomplished by using the concatenation operator to create a call to a type sensitive function based on the parameter passed to the macro/program/module/function.

0 0

Techtok replied | 19/08/2016

By using concatenation operator we can create a type-insensitive macro.

For Example:

#define ADD(data_type) add_ ## data_type
void add_int(int i, int j)
{
int h = i+j;
printf("%d",h);
}
void add_float(float k, float l)
{
float m = k+l;
printf("%f",m);
}

void main(void)
{
int a=1, b=1;
float...  more»
By using concatenation operator we can create a type-insensitive macro.

For Example:

#define ADD(data_type) add_ ## data_type
void add_int(int i, int j)
{
int h = i+j;
printf("%d",h);
}
void add_float(float k, float l)
{
float m = k+l;
printf("%f",m);
}

void main(void)
{
int a=1, b=1;
float c=1.1, d=1.1;
ADD(int)(a,b);
ADD(float)(c,d);
}

here, ADD(int)(a,b); translates into add_int(a,b); «less

0 0

Answer

You can add upto 6 Images

H

Harsh 15/07/2016 in  C Language Classes

How can a program be made to print the name of a source file where an error occurs?

0 0 3

Show previous answers

Sg replied | 17/07/2016

Use __FILE__ example:
printf("Error here File: %s, line: %d", __FILE__, __LINE__);

0 0

Raju replied | 18/07/2016

U can use __FILE__ global identifier

0 0

Answer

You can add upto 6 Images

Previous12345678Next

Have a Question?

Thousands of expert tutors are available to answer your question

Looking for C Language Classes?

Find best C Language Classes in your locality on UrbanPro.

FIND NOW

Do you offer C Language Classes?

Create Free Profile Now »

Top Contributors

Umasankar

52 Answers

Vinod

46 Answers

Sg

44 Answers

Dishaapro

44 Answers

Harish

44 Answers

Maqubool

32 Answers

Algorithm Class

25 Answers

Chetan

25 Answers

Rahul P

22 Answers

Sponsored

About UrbanPro

UrbanPro.com helps you to connect with the best C Language Classes in India. Post Your Requirement today and get connected.

Find Best C Language Classes?

Find Now »