• warning: Creating default object from empty value in /home1/gambalul/public_html/guruquiz/modules/taxonomy/taxonomy.pages.inc on line 34.
  • strict warning: Non-static method view::load() should not be called statically in /home1/gambalul/public_html/guruquiz/sites/all/modules/views/views.module on line 879.
  • strict warning: Declaration of views_handler_field_user::init() should be compatible with views_handler_field::init(&$view, $options) in /home1/gambalul/public_html/guruquiz/sites/all/modules/views/modules/user/views_handler_field_user.inc on line 48.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home1/gambalul/public_html/guruquiz/sites/all/modules/views/handlers/views_handler_filter.inc on line 589.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home1/gambalul/public_html/guruquiz/sites/all/modules/views/handlers/views_handler_filter.inc on line 589.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home1/gambalul/public_html/guruquiz/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 149.
  • strict warning: Declaration of views_plugin_style_default::options() should be compatible with views_object::options() in /home1/gambalul/public_html/guruquiz/sites/all/modules/views/plugins/views_plugin_style_default.inc on line 25.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home1/gambalul/public_html/guruquiz/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home1/gambalul/public_html/guruquiz/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.
  • strict warning: Non-static method view::load() should not be called statically in /home1/gambalul/public_html/guruquiz/sites/all/modules/views/views.module on line 879.

C programming language

C language quiz

You can find good C questions in the following C language quizzes:

C is a computer programming language

C is a general-purpose computer programming language originally developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. C has won widespread acceptance because it gives programmers precise control and efficiency to the programmer. Programmers who are familiar with the use of pointers (or indirect addressing) will welcome the ease of use compared with some other languages. In C, all executable code is contained within functions. Function parameters are always passed by value. Pass-by-reference is achieved in C by explicitly passing pointer values. C is block structured, and designed for procedural and imperative programming. Although C was designed for implementing system software, it is also widely used for developing application software. C has now become a widely used professional language for various reasons: C is an easy language to learn, it has high-level constructs, it can handle low-level activities, it produces efficient programs and it can be compiled on a variety of computers.

It is hoped that newcomers will find C a useful and friendly language.

Some of C's characteristics

Below is a list of C's characteristics that define the language and also have lead to its popularity as a programming language.

  • Small size (terse and cryptic in its style)
  • Extensive use of function calls (all executable code is contained within functions)
  • Loose typing (unlike ADA or PASCAL)
  • Structured language (Programs are structured by defining and calling functions)
  • Low level (Bit Wise) programming readily available
  • Pointer implementation (extensive use of pointers for memory, array, structures and functions)

C is a compiled language

This means that once you write your C program, you must run it through a C compiler to turn your program into an executable that the computer can run (execute). This means that to write and run a C program, you must have access to a C compiler. C language was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal runtime support. C was therefore useful for many applications that had formerly been coded in assembly language. It is widely used on a great many different software platforms and computer architectures, and several popular compilers exist. C has greatly influenced many other popular programming languages, most notably C++, which originally began as an extension to C. Despite its low-level capabilities, C language was designed to encourage machine-independent programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with little or no change to its source code. The language has become available on a very wide range of platforms, from embedded micro controllers to supercomputers.

C drawbacks

Its main drawback is that it has poor error detection which can make it unappealing to the beginner. However, by knowing the rules of C one can break them. This if done properly and carefully leads to the power of C programming. The fact that C is a bit more terse and cryptic in its style than some other languages can result in short efficient programs but also allows the programmer to produce programs which are impossible to understand. Care must be taken in using C. Many of the extra facilities which it offers can lead to extra types of programming error (Undisciplined use of pointers can lead to errors which are very hard to trace). One will have to learn to deal with these to successfully being a good C programmer.

C Unspecified and Undefined Behavior

Undefined behavior indicates that an implementation may behave unpredictably when a program reaches a certain state, which almost without exception is a result of a bug. Undefined behavior is always undesirable and should never occur. Sometimes in practice what happens for an instance of undefined behavior is a bug that is hard to track down and which may corrupt the contents of memory. Examples of undefined behavior are:

  • freeing the same memory chunk twice
  • accessing outside the bounds of an array
  • overflowing a signed integer
  • reaching the end of a non-void function without finding a return statement, when the return value is used
  • reading the value of a variable before initializing it
  • the behavior of the top bit when right shifting integer quantities

Unspecified behavior, on the other hand, is a feature that means that the specification leaves intentionally unspecified the results of certain operations to simplify the specification and allow some flexibility in implementation. It is guaranteed that the behavior of a certain implementation in such cases is consistent on the same machine. It is not guaranteed, however, that the behavior will preserve on another machine. Unspecified behavior is usually something you shouldn't worry about, unless your software is required to be portable. Examples of unspecified behavior are:

  • the size of an int,
  • whether a char is unsigned or signed by default,
  • the size of a pointer,
  • the underlying type representing a bool.

In C, even the compiler is not bound to behave in a sensible manner once Unspecified behavior or Undefined behavior has been invoked. The reason some behavior has been left unspecified is to allow compilers for a wide variety of instruction set architectures to generate more efficient executable code for well-defined behavior, which was deemed important for C's primary role as a systems implementation language; thus C makes it the programmer's responsibility to avoid unspecified behavior. Many programming languages has undefined and unspecified behaviors. By learning and knowing these behaviors the programmer can write stable and efficient programs.

C language arrays

An array lets you declare and work with a collection of values of the same type. For example, you might want to create a collection of seven integers. The seven separate integers inside this array are accessed by an index. All arrays start at index zero and go to n-1 in C.

Note: C has no range checking, so if your index past the end of the array, it will not tell you about it. It will eventually crash or give you garbage data.

C language Pointers

C supports the use of pointers, a very simple type of reference that records, in effect, the address or location of an object or function in memory. C pointers are characterized by their value and data-type.The value is the address of the memory location the pointer points to and the type determines how the pointer will be incremented/decremented in pointer arithmetic.

C uses pointers in three different ways:

  • C uses pointers to create dynamic data structures (data structures built up from blocks of memory allocated from the heap at run-time).
  • C uses pointers to handle variable parameters passed by reference to functions.
  • Pointers in C provide an alternative way to access information stored in arrays. Pointer techniques are especially valuable when you work with strings. There is an intimate link between arrays and pointers in C.

In some cases, C programmers also use pointers because they make the code slightly more efficient.

Arrays and Pointers in C language

The concept of array is very much bound to the one of pointer. In fact, the identifier of an array is equivalent to the address of its first element, as a pointer is equivalent to the address of the first element that it points to, so in fact they are the same concept. However, there is a distinction to be made between arrays and pointer variables. Even though the name of an array is in most expression contexts converted to a pointer (to its first element), this pointer does not itself occupy any storage. Consequently, you cannot change what an array "points to", and it is impossible to assign to an array.

Test your C programming knowledge

Test your programming knowledge with our C language programming quizzes. Don't forget to bookmark this site and check back for user generated frequent updates. Here, in this category, you can test your C language understanding. You can view other users answers, explains and questions discussions. In addition you can participate in the discussions or contribute your own c language questions.

You can now sign up to be notified of changes, add new quizzes, discuss quizzes or improve existing !

c language chapters 2 and 3

Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Backwards navigation:Allowed

http://www.guruquiz.com/content/c-language-chapters-2-and-3

Start quiz

All pointers arithmetic operations can be applied on argv

True/false question

The main function parameter named argv is a pointer to an array. Hence, all pointers arithmetic operations can be applied on it.

we can't control the way the array is allocated

True/false question

In ANSI C, we can't control the way the array is allocated and we can't be sure that the array will be allocated in a sequential place.

Function calling main function

Multiple choice question

What is the output of the following code:

#include <stdio.h>

void m(int argc, char *argv[])
{
   main(argc,argv);
}

void main(int argc, char *argv[])
{
   if (argc>0)
   {
     printf("%s\n", *argv);
     argc--;
     argv++;
     m(argc,argv);
   }
}

Each switch value must be constant integer

True/false question

The switch statement is a multi-way decision that tests whether an expression matches one of a number of constant integer values, and branches accordingly.

Precedence and Associativity of the pointer and increment operators

Multiple choice question

What is the following statement do?

x = *ip++;

logical operators precedence

Multiple choice question

Which of the following is evaluated first:
&&
||
!

count number of 1 bits

Multiple choice question

What will this function return? Does it work for negative numbers?

int myFunc(int num){
  int ret;
  for (ret=0 ; num!=0 ; num&=(num-1))
   ret++;
  return ret;
}

integral division

Multiple choice question

What does the expression 3/5*5 equals to?

Evaluate the following expression: !(0 && 0 |...

Multiple choice question

Evaluate the following expression:
!(0 && 0 || !0)

Syndicate content