Thursday 13 September 2007

C best coding questions with answer

(q) What will be output of the following program ?   #include"stdio.h" void  main(){ long double a=55555; clrscr(); printf("%.2LE,%.2Le",a); getch();   }   output:5.56E+04,5.56e+04 %e or %E represent print the number in exponential format. %e means output has small letter e. %E means output has capital letter e.   (q) What will be output of the following program ?   #include"

C best language questions and answer

(q) What will be output of the following program ?   #include"stdio.h" void  main(){ char a='\377'; clrscr(); printf(2+"%d%o",a); getch();   }   output:177777 Explanation: ‘\377’ is octal character constant. %o is used to print octal number system. (q) What will be output of the following program ?   #include"stdio.h" void  main(){ char a='\378'; clrscr(); printf("%o",a);

C coding good questions and answer



C coding good questions and answer



(1) What
will be output of the following code?



#include"stdio.h"

void  main(){

char
a='\\';

clrscr();

a=a-'/';

printf("%d",a);

getch();



}



Output: error



Explanation:

Character is \ has special meaning
in c programming. For example:



‘\0’ represents octal character.

‘\n’ represents new line character.
So we cannot use ‘\’ directly.



(2

C good questions and answer




Good questions in c programming language.



(1) What will be output
of the following program?



void  main(){

enum data{a,b,c};

clrscr();

printf("%i %i %i",a,b,c);

getch();

}



Output: 0 1 2

Explanation:

By default initial
value of first enum constant is zero. Value of next enum constant
will be:

Next_enum_constant_value=previous_enum_constant_value+1



(2) What will be output
of

good questions of c with answer



Volatile modifier keyword
questions in c programming language:

(q) What will be output of the
following program?



void main()

{

volatile a=5;

a=~a+ ++a;

clrscr();

printf("%d",a);

getch();

}

Output: -1

Explanation: 

Volatile variable can be modifying by interrupt or other
process in preprocessor. So in normal output will not affect.

Note. ~ is one’s complement operator



(q) What

Saturday 1 September 2007

Properties of constructor in c++ with example

Properties of constructor:
(1) Constructor is special type function which must has same name of class name.
(2) Constructor doesn’t return any data type even void
Example:
#include
#include
class school
{
char *name;
int capacity;
public:
void school();
void display()
{
cout<
#include
class math
{
int a;
float b;
public:
math(int p,float q) //constructor should be in

Why constructor in c++

(q) Why constructor ?
Ans:
Goal of c++ is to create such type of class which is very similar to basic data type like int
char,float etc.
It is possible in basic data type like int,char etc we can initialize the data type at the
time of creation .
Example:
#include
#include
int main()
{
int a=6; //intialization at the time
char b='v'; // of creation

What is printf in c or prototype of printf with example



(q) What is prototype of printf function? Explain each term.



Answer:

Prototype of printf function is:

int printf( const char *format ,…)



Explanation of each term:

Parameter of printf function is:

(1) … (Three continuous dots): It is called ellipsis. It indicates the variable number of arguments.

Example of ellipsis:



void ellipsis(int a,...);

void main()

{

int a=5,b=10;