Programming, website development forum Get latest updates by RSS Follow TechnicalTalk on Twitter Follow TechnicalTalk on Facebook 
HomeSearchRecent PostsLoginRegisterContact Us

Username  
Password    
  Forgot your password?  

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

Frequently asked C Questions - C FAQs - Interview Questions

 
webmaster forum
Admin  Offline
*
 
Code Guru
Location: India
Gender: Male
Posts: 1387
Topics: 105
NaviBuster NaviBuster
WWW
December 13, 2008, 05:58:21 AM

Here we are trying to collect all the frequently asked questions on basic C programming language. The questions and answers listed in this thread are collected from regular posts by our forum member. You can use them in your interview also. We will try to update this thread regularly, and we are also open for your suggestions.

You may find solution to your programming problem/question in this thread; therefore go through this thread carefully if this is your first visit to the forum in search of some solution.

« Last Edit: May 13, 2011, 05:41:53 AM by Admin »
 
webmaster forum
polas  Offline
Activity
33.33%
 
Code Guru
Gender: Male
Posts: 1399
Topics: 85
WWW
December 15, 2008, 05:13:55 AM

I think operator precedence and associativity is always a favourite one, for instance (without using running it),

int c=55;
int d=823;
int a=++d * c + 99 - 72++

Whats a? - This is just one I have thrown together, but its an illustration of how important it is to know this when writing code - or else you will get bogged down in parenthesis.

Or, heres another one, quite a common newbie missunderstanding,  - why does the following code not work.

#include <stdio.h>
char * myfunction();
int main()
{
 char * data=myfunction();
printf("%c\n",data[1]);
return 0;
}

char * myfunction()
{
  char myarray[]={'h','e','l','l','o'};
  return myarray;
}
« Last Edit: December 15, 2008, 05:40:43 AM by polas »

Mesham Type Oriented Parallel Programming Language, Free online technical support
 
webmaster forum
vijay12  Offline
Activity
0%
 
Regular Coder
Posts: 67
Topics: 33
January 01, 2009, 09:57:46 PM

the questions frequently asked in c are,
1.structure of C program.
2.operators in C
3.explain functions, variables, arrays etc., with syntax.
4.what is a compiler.
 
webmaster forum
lisaroy1  Offline
Activity
0%
 
New Poster
Gender: Female
Posts: 8
Topics: 1
WWW
February 09, 2011, 03:11:36 AM


Q. What is the difference between text and binary modes?
Ans-
  Streams can be classified into two types: text streams and binary streams.  Text streams are interpreted, with a maximum length of 255 characters.  With text streams, carriage return/line feed combinations are translated to the newline n character and vice versa.  Binary streams are uninterpreted and are treated one byte at a time with no translation of characters.  Typically, a text stream would be used for reading and writing standard text files, printing output to the screen or printer, or receiving input from the keyboard.

A binary text stream would typically be used for reading and writing binary files such as graphics or word processing documents, reading mouse input, or reading and writing to the modem.
 
webmaster forum
Activity
0%
 
Skilled Coder
Posts: 125
Topics: 0
February 09, 2011, 03:31:50 AM

As per my Suggestion following questions are frequently ask in Interview.

- Difference between Function overloading and Function over ridding.
- Difference between Friend function and Normal Function.  

Network Management Service
 
webmaster forum
Activity
0%
 
New Poster
Posts: 4
Topics: 0
May 13, 2011, 04:35:09 AM

1. how to create love flames program using c language    

#include<stdio. h>
#include<conio. h>
#include<string. h>
void main()
{
int i,j,n,c,s=0,p,t,y;
char a[25],b[25],m,q[25],w[25];
clrscr();
printf("Enter Ur Name
");
scanf("%s",a);

printf("Enter Ur Partner's Name
");
scanf("%s",b);
strcpy(q,a);
strcpy(w,b);
n=strlen(a);
c=strlen(b);
for(i=0;i<n;i++)
{
m=a;
for(j=0;j<c;j++)
{
if(m==b[j])
{
a=-1;
b[j]=-1;
s=s+2;
break;
}
}
}
p=n+c;
puts(a);
puts(b);
t=p-s;
printf("The count value is %d",t);

if(t==2 || t==4 || t==7 ||t==9 )
printf("
%s is ENEMY to %s ?,q,w);
else if (t==3 || t==5 || t==14)
printf("
%s is FRIEND to %s ",q,w);
else if(t==6 || t==11 || t==15 )
printf("
%s is going to MARRY %s ?+?",q,w);
else if(t==10)
printf("
%s is in LOVE with %s ",q,w);
else if(t==8)
printf("
%s has more AFFECTION on %s ",q,w);
else
printf("
%s and %s are SISTERS/BROTHERS ",q,w);
getch();
}
   
2. How can you avoid including a header more than once?

One easy technique to avoid multiple inclusions of the same header is to use the #ifndef and #define
preprocessor directives.  When you create a header for your program, you can #define a symbolic name that is unique to that header.  You can use the conditional preprocessor directive named #ifndef to check whether that symbolic name has already been assigned.  If it is assigned, you should not include the header, because it has already been preprocessed.  If it is not defined, you should define it to avoid any further inclusions of the header.  The following header illustrates this technique:

#ifndef _FILENAME_H
#define _FILENAME_H
#define VER_NUM ?1. 00. 00?
#define REL_DATE ?08/01/94?
#if _ _WINDOWS_ _
#define OS_VER ?WINDOWS?
#else
#define OS_VER ?DOS?
#endif
#endif

When the preprocessor encounters this header, it first checks to see whether _FILENAME_H has been defined.  If it hasn?t been defined, the header has not been included yet, and the _FILENAME_H symbolic name is defined.  Then, the rest of the header is parsed until the last #endif is encountered, signaling the end of the conditional #ifndef _FILENAME_H statement.  Substitute the actual name of the header file for ?FILENAME? in the preceding example to make it applicable for your programs
« Last Edit: May 13, 2011, 05:35:28 AM by Admin »
 
webmaster forum
Life Is Good!
Activity
0%
 
Professional Coder
Gender: Female
Posts: 242
Topics: 3
WWW
May 20, 2011, 08:46:19 AM

As per my Suggestion following questions are frequently ask in Interview.

- Difference between Function overloading and Function over ridding.
- Difference between Friend function and Normal Function.   


do you have answers to these questions..?

Affordable Custom Web Design Services
 
webmaster forum
netshet  Offline
Activity
6.67%
 
Regular Coder
Posts: 73
Topics: 2
WWW
August 15, 2011, 12:41:06 AM

.    What's the difference between a structure and a union, anyway?
   A union is essentially a structure in which all of the fields overlay each other; you can only use one field at a time. (You can also cheat by writing to one field and reading from another, to inspect a type's bit patterns or interpret them differently, but that's obviously pretty machine-dependent.) The size of a union is the maximum of the sizes of its individual members, while the size of a structure is the sum of the sizes of its members. (In both cases, the size may be increased by padding.
 
    What's the difference between ++i and i++?
   ++i adds one to the stored value of i and ``returns'' the new, incremented value to the surrounding expression; i++ adds one to i but returns the prior, unincremented value.

hair transplant
 
webmaster forum
Activity
0%
 
New Coder
Posts: 41
Topics: 0
WWW
September 21, 2011, 03:38:09 AM

Overloading - Two functions having same name and return
type, but with different type and/or number of arguments.  
Overriding - When a function of base class is re-defined in
the derived class.

Display Banner | Pull Up Banner
 
webmaster forum
polas  Offline
Activity
33.33%
 
Code Guru
Gender: Male
Posts: 1399
Topics: 85
WWW
September 29, 2011, 02:34:09 PM

   What's the difference between ++i and i++?
   ++i adds one to the stored value of i and ``returns'' the new, incremented value to the surrounding expression; i++ adds one to i but returns the prior, unincremented value.


Almost, the question is that of precidence. So in C prefix (++i) has a very high precidence (higher than =) whereas postfix (i++ ) very low (lower than =.) So in the expression a = i++ it will perform the equals operation (i.e. assign to variable a the value of i) before it does the increment

Mesham Type Oriented Parallel Programming Language, Free online technical support
 
webmaster forum
Activity
0%
 
New Poster
Posts: 4
Topics: 0
November 03, 2011, 08:32:03 AM

what is the difference between c and c++
« Last Edit: November 09, 2011, 10:18:27 PM by Admin »
 
webmaster forum
FUE hair transplant in Pakistan
Activity
0%
 
New Coder
Real name: Harry Martin
Location: Pakistan
Gender: Male
Posts: 26
Topics: 0
WWW
November 04, 2011, 10:53:49 PM

The difference is obvious and please see the above answers for your explaination
 
webmaster forum
Activity
100%
 
Regular Coder
Posts: 77
Topics: 0
January 09, 2012, 10:01:41 AM

   What does extern mean in a function declaration?
extern is significant only with data declarations. In function declarations, it can be used as a stylistic hint to indicate that the function's definition is probably in another source file, but there is no formal difference between extern int f(); and int f();

How are structure passing and returning implemented?
When structures are passed as arguments to functions, the entire structure is typically pushed on the stack, using as many words as are required. (Programmers often choose to use pointers to structures instead, precisely to avoid this overhead.) Some compilers merely pass a pointer to the structure, though they may have to make a local copy to preserve pass-by-value semantics.Structures are often returned from functions in a location pointed to by an extra, compiler-supplied ``hidden'' argument to the function. Some older compilers used a special, static location for structure returns, although this made structure-valued functions non-reentrant, which ANSI C disallows.

Yellow Pages of Pakistan
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.15 | SMF © 2011, Simple Machines


Google visited last this page February 02, 2012, 07:38:48 PM