Question of c preprocessor with detailed solution

C programming preprocessor questions and explanations

(1) What will be output of following code?


#include<stdio.h>
#define max 10

int main(){

    int i;

    i=++max;

    printf("%d",i);

    return 0;
}


(2) What will be output of following code?


#include<stdio.h>
#define max 10+2

int main(){

    int i;

    i=max*max;

    printf("%d",i);

    return 0;
}


(3) What will be output of following code?


#include<stdio.h>
#define A 4-2

#define B 3-1

int main(){

     int ratio=A/B;

     printf("%d ",ratio);

     return 0;
}


(4) What will be output of following code?


#include<stdio.h>
#define MAN(x,y) (x)>(y)?(x):(y)

int main(){

       int i=10,j=9,k=0;

       k=MAN(i++,++j);

       printf("%d %d %d",i,j,k);

       return 0;
}


(5) What will be output of following code?


#include<stdio.h>
#define START main() {

#define PRINT printf("*******");

#define END }

START

PRINT

END


(6) What will be output of following code?


#define CUBE(x) (x*x*x)

#define M 5

#define N M+1

#define PRINT printf("RITESH");

int main(){

      int volume =CUBE(3+2);

      printf("%d %d ",volume,N);

      PRINT

      return 0;
}


Solution section 


(1)
output: compiler error.
Explanation:


Here max is preprocessor macro symbol which process first before the actual compilation. First preprocessor replace the symbol to its value in entire the program before the compilation. So in this program max will be replaced by 10 before compilation. Thus program will be converted like this:

int main(){

     int i;

     i=++10;

     printf("%d",i);

     return 0;
}


In this program we are trying to increment a constant symbol.


Meaning of ++10 is:
10=10+1
or 10=11


Which is error because we cannot assign constant value to another constant value .Hence compiler will give error.

(2)


Output: 32
Explanation:


Here max is preprocessor macro symbol which process first before the actual compilation start. Preprocessor replace the symbol to its value in entire the program before the compilation. So in this program max will be replaced by 10+2 before compilation. Thus program will be converted as:
 
int main(){

    int i;

    i=10+2*10+2;

    printf("%d",i);

    return 0;
}


now i=10+2*10+2
i=10+20+2
i=32

(3)


Output: 3
Explanation:

A and B are preprocessor macro symbol which process first before the actual compilation start. Preprocessor replace the symbol to its value in entire the program before the compilation. So in this program A and B will be replaced by 4-2 and 3-1 respectively before compilation. Thus program will be converted as: 

int main(){

    int ratio=4-2/3-1;

    printf("%d ",ratio);

    return 0;
}


Here ratio=4-2/3-1
ratio=4-0-1
ratio=3

(4)


Output: 11 11 11

Explanation:


Preprocessor’s macro which process first before the actual compilation. Thus program will be converted as: 

int main(){

    int i=10,j=9,k=0;

    k=(i++)>(++j)?(i++):(++j);

    printf("%d %d %d",i,j,k);

    return 0;
}


now k=(i++)>(++j)?(i++):(++j);
first it will check the condition
(i++)>(++j)


i++ i.e. when postfix is used with variable in expression then expression is evaluated first with original value then variable is incremented


Or 10>10


This condition is false.
Now i = 10+1 = 11
There is rule, only false part will execute after? i.e. ++j, i++ will be not execute.
So after ++j
j=10+1=11;


And k will assign value of j .so k=11; 

(5)


Output: *******
Explanation:

This program will be converted as: 

main(){

    printf("*******");

}


(6)


Output: 17 6
Explanation: This program will be converted as:

int main(){

    int volume =(3+2*3+2*3+2);

    printf("%d %d ",volume,5+1);

    PRINT

    return 0;
}


If you have any quires or suggestions in above question of c preprocessor with  detailed solution, you can ask here.

111 comments:

Unknown said...

I want to make program of rotating cube in c platform i write all command or left right up down keys but i have no idea how to make calculation (matrix) to change direction
please help me if u have any idea

Unknown said...

I HAVE A DOUBT TO WRITE C/C++ PROGRAM TO DISPLAY
*** *** ***
* ** *
*

siva said...

Could you please help me to create hash table using linked list to know details?

K K said...

i need a program which does copy command(in dos) function.
for ex:
in dos we give this command to copy files.
copy file1 file2.
I need to implement this with c or c++ program. n the main function of the pgm should start lik this.
int main(int argc,char **argv)
{
//code
}
the prog should the function of copying of files..
help me out to construct the code for this program.

Unknown said...

how to write a c program to display the source code of the program.

Anonymous said...

I want a C program to check whether a string is a palindrome or not where the string to be checked is passed as command line argument during execution.

swapnil said...

thank u it was very helpfull to me thank u very much

Anonymous said...

Hi!
I hope u will be fine.plz help in following program.I need sourse code.

The question is:
A string (eg: "I am writting an email") is entered through the keyboard, write a programe in C to get its reverse in a coluumn as output ie:
email
an
writting
am

I

Anonymous said...

I have trouble with a program that needs to store and add polynomials using linked lists. Something like:
A = a_0 + a_1x + a_2x^2 + ... and B = b_0 + b_1x + b_2x^2 + ...,

compute

A + B = (a_0+b_0) + (a_1+b_1)x + (a_2+b_2)x^2 + ....

Thanks!

Unknown said...

Hi
This site is more helpful to think logically and mentally in C.....

Thanks

Priyanka kumari said...

Hi!
I hope u will be fine.plz help in following program.I need source code.

The question is:
A string (eg: "I am writing an email") is entered through the keyboard, write a programme in C to get its reverse in a column as output ie:
email
an
writing
am

I
Answer:
code for such program is:
void main()
{
char str[20];
char *ptr=str,*temp;
int i=0,j;
clrscr();
scanf("%[^\n]",str);
while(*ptr){
i++;
ptr++;
}
for(j=0;j
if(*ptr==' ')
{
temp=ptr;ptr--;temp++;
while((*temp!=' ')&&(*temp!='\0')) {
printf("%c",*temp);
temp++;
}
printf("\n");
}
else
{
ptr--;
}
}
while(*ptr!=' ') {
printf("%c",*ptr);
ptr++;
}
getch();
}

Priyanka kumari said...

i need a program which does copy command(in dos) function.
for ex:
in dos we give this command to copy files.
copy file1 file2.
solution:
/* to work in all directory write in command prompt
path=c:\tc\bin
code:
#include"dos.h"
#include"stdio.h"
void main(int argc,char *argv[])
{
FILE *fp1,*fp2;
char ch;
if(argc>3)
printf("Syntax of command is incorrect");
fp1=fopen(argv[2],"w");
fp2=fopen(argv[1],"r");
if(fp2==NULL)
printf("System cannot find the file specified.");
else {
printf("1 file(s) copied.");
while((ch=getc(fp2))!=-1)
putc(ch,fp1);
}
fclose(fp1);
fclose(fp2);

}

Priyanka kumari said...

how to write a c program to display the source code of the program.

(ramya)

8/23/08

answer:

If source code is available

#include"stdio.h"

void main()

{

char str[70];

FILE *p;

clrscr();

if((p=fopen("mod.c","r"))==NULL)

{

printf("\nUnable t open file string.txt");

exit(1);

}

while(fgets(str,70,p)!=NULL)

puts(str);

fclose(p);

getch();

}
//if source code is not persent then ...... i will post later

Priyanka kumari said...

I want a C program to check whether a string is a palindrome or not where the string to be checked is passed as command line argument during execution.
(pahal ray
8/25/08
Answer:
#include"string.h"
void main(int counter,char **string)
{
char *rev;
char str[15];
int i,j;
clrscr();
strcpy(str,string[1]);
printf("%s",str);
for(i=strlen(str)-1,j=0;i>=0;i--,j++)
rev[j]=str[i];
rev[j]='\0';
if(strcmp(rev,str))
printf("\nThe string is not a palindrome");
else
printf("\nThe string is a palindrome");
getch();
}

Swapnil Kalamkar said...

i have 2 learn c from basic so please provide me a web sites or link which can give solustion with there explanation

Swapnil Kalamkar said...

i have 2 learn c from basic so please provide me a web sites or link which can give solustion with there explanation

sp.shakeera said...

I want to executive reverse a number prograin pl sql.

Unknown said...

sir i have doubt in c language.
when i will create two variables in global section ,its takes but it does not give error
but if i intialize with two value for that varaibles ,it gives error
i want to know the reason

Anonymous said...

how can we write a program seeking a text input and a code input form keyboard. compare these two and check the occurrence of the code within the text and its position where it is located.

thank you.

Anonymous said...

what is command line argument?

Anonymous said...

Write a programme in C, complex numbers Addition, Substractio, Multiplication & Division using Struture.

Anonymous said...

write a program that print the factorial of a given nomber using a constructor and a destructor as member function in c++

Anonymous said...

thank u

Priyanka kumari said...

(q)Write a programme in C, complex numbers Addition, Substractio, Multiplication & Division using Struture.
Answer :

typedef struct number
{
int a;
int b;
}complex;
complex add(complex,complex);
void display(complex);
void main()
{
complex c1={2,2},c2={6,6},c3;
clrscr();
c3=add(c1,c2);
display(c3);
getch();
}
void display(complex c3)
{
printf("%d + %d i",c3.a,c3.b);
}
complex add(complex c1,complex c2)
{
complex temp;
temp.a=c1.a+c2.a;
temp.b=c1.b+c2.b;
return temp;
}
output: 8+8i
In same way you can write subtract,mutiplication and division function. Well for asking questions.

Unknown said...

a book shop maintains an inventory of books that are being sold at the shop. The list includes details such as author, title, publisher and stock position. Whenever a customer wants a book, the sales person inputs the title and author and the system searches the list and displays whether it is available or not. If it is not, an appropriate message is displayed. If it is, then the system displays the book details and requests for the number of copies required. If the requested copies are available, the total cost of the required copies is displayed, otherwise the message "sorry these many copies are not in the stock" is displayed. Design a system using a class called stock with suitable member functions and constructors.

DV (veeru) said...

I have a doubt in C progtaaming.

Q. Write a C programm to find duplicate in the array.

Anonymous said...

HI
how can i write aprograme that used to input set of numbers up to 1 bilion and output them in reverse order without using any type of arrays or list
for example input= 1 4 6 90 23
output = 23 90 6 4 1

thanx

nitish02 said...

hi
pls solve my prob. about c

{
int a=5;
a=(a++)+(++a);
printf("%d",a);
}

out put is=13


and if we take b in place of a
as.

{
int a=5;
b=(a++)+(++a);
printf("%d",a);
}

out put is=12

why the out put is differ.

Anonymous said...

hi there!!! can u please help me out with this program..


the question is to create a child process and synchronize it with the parent process using c programming language.. i'l be waiting for the solution.. please do it as soon as possible

vrchand said...

give a C program to foll. output
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

vrchand said...

give a c prog to get foll output
phy***chem***math***
100 90 29
2 2 45
45 7 15

Priyanka kumari said...

SOLUTUIONS OF YOUR DOUBT
hi
pls solve my prob. about c

{
int a=5;
a=(a++)+(++a);
printf("%d",a);
}

out put is=13


and if we take b in place of a
as.

{
int a=5;
b=(a++)+(++a);
printf("%d",a);
}

out put is=12

why the out put is differ.

Solution:
++a: ++ is pre increment operator.
In any statement first it increment the value one by one at the end of statement then it assigne same value to all variable.
e.g
int p=0,a=2;
p=++a + ++a + ++a;
first increment: ++a=3
second increment: ++a=4
third increment:++a=5
so final value of a is 5
now it will start assigne 5 to all
a in the statement.
a=5;
p=5+5+5;
p=15;

a++: it first assine the initial value to all a then start increment
on by one at the end of statement.
e.g:
int a=2,p=0;
p=a++ + a++ +a++;

first it will assigne 2 to all a
p=2+2+2;
p=8;
now it will statrt increment the a.
first increment: a++=3
second increment: a++=4
third increment:a++=5
so final value of a is 5
now I come to your question:
int a=5;
a=(a++)+(++a);
....5.....6...
(++a has incremente but not ++a)
now 6 will assing both a
i.e
a=6+6;
a=12
now a++ will increment,
so a=12+1=13.
in second case.
int a=5,b=0;
b=(a++)+(++a);
b=..5.....6..
final value of a is 6
now it will assigne to both a.
b=6+6;
b=12
now a++ will increment.
a=6+1=7

If you have any doubt you can ask.....

Anonymous said...

sir,
I have doubt in c
In 32-bit compiler "int" will occupy 4Bytes and "long int" will also occupy 4Bytes.
when "int" is occuping 4 bytes what is use of "long int"

Priyanka kumari said...

For 32 bit compiler there is not any meaning of long int.

Unknown said...

how is the statement inside printf statement evluated?
left to right
or right to left.
how you can say so.

Anonymous said...

can I post my question and my solution for you guys to check for me please?

Unknown said...

wap to print the followinf

*
***
*****
*******

Unknown said...

wap to print the series
1^2+2^2+3^2+4^2..............

Priyanka kumari said...

how is the statement inside printf statement evluated?
left to right
or right to left.
how you can say so.
Answer: Kislay inside printf evaluation of statement depends upon which compiler you are using.
For TURBO C it is from left to right.
solve this:
void main(){
int a=5;
printf("%d%d%d",++a,++a,++a);
}

More detail search in this blog prototype of printf
Function passing scheme pascal,cdecl
Input output questions
more detail

Priyanka kumari said...

TobY:
can I post my question and my solution for you guys to check for me please?
Answer:
I am waiting to you. If you have good questions of c with solutions then post those questions in comment section then i will publish those questions in the blog including your name

Priyanka kumari said...

isha
wap to print the followinf

*
***
*****
*******
Answer:
void main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<2*i-1;j=j+1)
{
printf("*");
}
printf("\n");
}
getch();
}

Thank you for query

rajnikant said...

i want to know the rogram that reads the age name and salary of 10 persons and maintain them in the sorted order

rajnikant said...

1)i wana know a program which counts number of words lines and characters in a given text?


2)program that accepts a number as input in english language format such that 123.one hundred thirty three and print the decimal of it?

manish said...

plz send me program of all #pragma directive used in c with explanation....my e mail is manish_jawla@yahoo.co.in plz its urgent send me as soon as possible....thank u..

manish said...

plz i need program on all #pragma directive..hdrstop,hdrfile,saveregs,option any plz hurry its urgent my e mail is manish_jawla@yahoo.co.in

manish said...

and thank u very much for your available notes on preprocessor they help me a lot..u are genious...awsome....thank u very much..

ARYAN said...

what is the output to
i=967;
printf("%d",printf("%d",printf("%d",i)));

Unknown said...

what would be the output of??
i=987;
printf("%d",printf("%d",printf("%d",i)));
explanation reqd also??

Priyanka kumari said...

hai ARUN
what would be the output of??
i=987;
printf("%d",printf("%d",printf("%d",i)));
explanation reqd also??
Output: 98731
Explanation: Return type of printf function is int i.e number of character it will print.
for example:
printf("world") will return 5
prinf("hello world") will return 10
now in your question:

printf("%d",printf("%d",printf("%d",i)));
first inner most printf function will print 987 and return 3
second printf will print 3 and return 1 and outter most printf will print 1

If you have even doubt then plz ask.

Anonymous said...

WAP in c using while how to display fibonacci series(0,0,1,1,2,3,5,8,13,21

Priyanka kumari said...

c using while how to display fibonacci series(0,0,1,1,2,3,5,8,13,21...)
Solution:


void main()
{
int i=0,j=1,k=2,r,f;
clrscr();
printf("Enter the number range:");
scanf("%d",&r);
printf("\nFIBONACCI SERIES: ");
printf("%d %d",i,j);
while(k{
f=i+j;
i=j;
j=f;
printf(" %d",j);
k++;
}
getch();
}

Anonymous said...

DEAR SIR,

PL GIVE ANSWER OF BELOW QUESTION

What is a Directed Graph? Write an algorithm to find whether a Directed Graph is connected or not.

Anonymous said...

how to draw a checker board in c++ using any loop

Anonymous said...

how to normalize huge pointer..need complte explanation..
a= (0x5999)* (0x10) + (0x0005)=0x9990+0x0005=0x9995

b= (0x5998)* (0x10) + (0x0015)=0x9980+0x0015=0x9995

how to calculate physical address?

Anonymous said...

What is ouput of the following code.. pls explain me with an example.
char *Util_ChaineConvMaj ( char *Chaine )

{
char *pChar ;
pChar = Chaine ;
while ( *pChar != NULLCHAR )
*pChar++ = toupper(*pChar) ;
return ( Chaine );
}

vivek kumar said...

Main() in C


Can anyone tell me main() is a user define function or library function. with explaination ?

Priyanka kumari said...

vivek kumar said...
Main() in C


Can anyone tell me main() is a user define function or library function. with explaination ?
Answer:
main() is not library function.It is special type user defined function.
As we know to use any library function we have not to write its function body.Directly we can call the function passing correct paramete.For example
printf("raja");
While for main function we have to define its function body.

Anonymous said...

Hai Friends Let i Have a Question to You

1. Without Intializing the Variable
(Either in both Local or Global)
We have to get the Input of
character from the user and check
that given character is Vowels
(or) Not Vowels. (Yes I Got the
Sol.)

Unknown said...

Hai Friends this is Rajendhiran from Pondicherry

I have another question like Previous Question (ie) without declaration of variables. To Find the Given Character is Vowel (or) Not Vowel

Now, 2nd Question is We want find the largest of two Nos without using the relational operator ie(> < >= <= = !=).

Priyanka kumari said...

Hai Friends this is Rajendhiran from Pondicherry

I have another question like Previous Question (ie) without declaration of variables. To Find the Given Character is Vowel (or) Not Vowel

Now, 2nd Question is We want find the largest of two Nos without using the relational operator ie(> < >= <= = !=).


solution of first question:
#include "math.h"
void main(){
int a,b;
int c;
clrscr();
scanf("%d%d",&a,&b);
c=a-b;
if(c){
if(c+abs(c))
printf("a is larger");
else
printf("b is larger");
}
else
printf("Both are equal");

getch();
}


Solution of second question:


void main(){
char ch;
clrscr();
scanf("%c",&ch);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
printf("Character is vovel");
else
printf("Chracter is not vovel");
getch();
}

naxalz said...

write a loop for which this is the output
1
22
333
4444
55555

ANAND said...

write the c program for finding the factorial value of 200 and greater number but the out put should be in integers with out including "e" value.

Unknown said...

wap to find sum of two matrix using funtion matrixadd

Priyanka kumari said...

void addmatrix();
void main(){
clrscr();
addmatrix();
getch();
}
void addmatrix(){
int a[2][3]={{1,2,3},{4,5,6}};
int b[2][3]={{5,10,15},{3,6,9}};
int c[2][3];
int i,j;
for(i=0;i<=1;i++)
for(j=0;j<=2;j++)
c[i][j]=a[i][j]+b[i][j];
for(i=0;i<=1;i++){
for(j=0;j<=2;j++)
printf("%d ",c[i][j]);
printf("\n");
}
}

Unknown said...

i want to write a program in c which will let the program to infect all files of a particular extension(say.avi) in all directories?????

Unknown said...

hoe to Write a C program to input multiple sequences of integers and output messages stating whether or not the respective series are super increasing.

input Format:

The number of terms to be input is not known, but you may assume that there are at least two values, and that the value -999 marks the end of a sequence. (-999 is not to be considered a data value.)

Anonymous said...

Programe to calculate compound interest on a given principle amount.

Unknown said...

i am not able to do the coding of output written below in C language

1 1
2 2
3 3
4 4
5
4 4
3 3
2 2
1 1

Unknown said...

i am not able to do the coding of output written below in C language

1 1
2 2
3 3
4 4
5
4 4
3 3
2 2
1 1
it is written in shape of "X"

Unknown said...

main() {

char s1[] = "Hagrid";

char s2[] = "Hagrid";

if (s1==s2)

printf ("Same");

else

printf ("Different");

}
Answer :: Different

Priyanka kumari said...

Hi Naveen

In c array name is constant pointer. It points the base address of the string. You are comparing s1 and s2 its means you are comparing base address of string "Hagrid" and string "Hagrid". Since these two strings has allocated different memory location so base address of two strings is also different. Hence output is: Different.

Unknown said...

my question is:
to find whether no. entered by user is prime or not? using recursion method in c++

Animesh said...

Please help me in forming pascals triangle using c++

Unknown said...

please tell me how to find the biggest of 5 numbers using pointers

Unknown said...

why resultant of modular division depends upon only the first operand

Unknown said...

why .com program runs faster than .exe program

Unknown said...

what is use of extended memory

ravitej said...

pl write a prgm to print d below series:
2+3/1!-6/2!+9/3!-12/4!+.....n terms

user gives input for n, and series shud evalute until nth term.. pl help..

Nihal Srivastava said...

Regarded SIr;
I want to create a program like that
N
NI
NIH
NIHA
NIHAL

in c language ,what code will be run?pl;z send me code on "write2nihal@gmail.com

Unknown said...

what is the c code for sorting a list of strings in alphabetical order using pointers?

Unknown said...

i want to know why this isnt showing the right ans. and i have the right program also but i dont know how is it working ,it will be really helpfull if u can tell me who is this working.
main(void)
{
int n,x;
printf("Enter the value of n : ");
scanf("%d",&n);
x=fibonacci(n);
printf("%d ",x);
getch();
return (0);
}

fibonacci(int number)
{
if ( ( number == 0 ) || ( number == 1 ) )
return number;
else
return fibonacci( number - 1 ) + fibonacci( number - 2 );
}




the program written below is working perfectly . can you explain me how is this working.
#include
#include
void fun(int a,int b);
int num;
void main()
{

printf("Enter The Limit :");
scanf("%d",&num);
printf("The Fibnocci Series Up To %d Is......nnt 0",num);
fun(0,1);
getch();
}

void fun(int a ,int b)
{
if(b>num)
return;
printf(" %d",b);
fun(b,a+b);
}

Unknown said...

i want to know why this isnt showing the right ans. and i have the right program also but i dont know how is it working ,it will be really helpfull if u can tell me who is this working.
main(void)
{
int n,x;
printf("Enter the value of n : ");
scanf("%d",&n);
x=fibonacci(n);
printf("%d ",x);
getch();
return (0);
}

fibonacci(int number)
{
if ( ( number == 0 ) || ( number == 1 ) )
return number;
else
return fibonacci( number - 1 ) + fibonacci( number - 2 );
}




the program written below is working perfectly . can you explain me how is this working.
#include
#include
void fun(int a,int b);
int num;
void main()
{

printf("Enter The Limit :");
scanf("%d",&num);
printf("The Fibnocci Series Up To %d Is......nnt 0",num);
fun(0,1);
getch();
}

void fun(int a ,int b)
{
if(b>num)
return;
printf(" %d",b);
fun(b,a+b);
}

Anonymous said...

hi..
can any1 tell me how to print the GCD of any n numbers??

Anonymous said...

Hi,
My query is in C programming:
Write a program to print first 25 prime numbers.

no said...

how to write a program to print nth largest number in an array

Unknown said...

i have to write a program in c language question is write a programme account system using file?

W batch :) said...

It would be excellent if you have provided solutions to all the objective questions.

Unknown said...

the distance between two cities is input through the keyboard.write a pgm to convert and print this distance in centimetres,feets,inches,meters

Unknown said...

I want multiple choice questions for C++...
Please suggest any book or link...

Unknown said...

Program for reverse a tree in c..plz help

Ajay said...

Hello sir,
I am BE(IT) passed out.
I just want to strong my logic and programming.
can you sugest any method.
As my project was in c#.net
I dont know much about java.
My dream is to open my own firm
can you sugest java will be useful for this.
I have basic knowlege about java.
But considerable knowlege of c#.
Plese help me.

Anonymous said...

my name is hari krishna my doubt is design and develop program for intersection union cartesian product in numeric data and in string data sets

namanipradeepkumar said...

please answer this question:

int main()
{
printf("one\t","two");
printf("one",printf("two"));
}
out put:-
one two
two one

why the second printf gives reverse ouput?
please give full explanation.

namanipradeepkumar said...

what is the output of the following program?


int main()
{
while(printf("hai");
}

namanipradeepkumar said...

what is the output of the following program?

int main()
{
printf("%d",printf("pradeep");
}

Unknown said...

how to create a binary tree using linked list?

Unknown said...

what is the size of a macro?

Priyanka kumari said...

keerthi
what is the size of a macro?
Answer

Macro in c is just like a symbolic name of any type of constantans. This constant may be integer constant, character constant, float constant, string constant etc. For example
#define symbol1 25
#define symbol2 ‘A’
#define symbol3 3.2f
#define symbol4 “cquestionbank.blogspot.com”

So size of any macro will depend upon a particular macro constant is symbol of which type constant. For example: Size of symbol1 is and symbol2 is 2 byte, size of symbol3 is 4 byte while size of symbol4 is 27 in Turbo c compiler.

Priyanka kumari said...

namanipradeepkumar
what is the output of the following program?

int main()
{
printf("%d",printf("pradeep");
}
Answer


If there is function call inside another function call then inner function will execute first.
printf("%d",printf("pradeep");
So, inner printf function will execute first. So first of all it will print pradeep
printf function returns number of characters it prints. In the above example inner printf function 7 characters. Hence outer function will print 7
Output: pradeep7

Priyanka kumari said...


namanipradeepkumar
what is the output of the following program?


int main()
{
while(printf("hai");
}
Answer:


printf function returns number of characters it prints. So in this case printf will return 3
So above code will be replaced as:
int main()
{
while(3);
}

In c any non zero is assumed as true. So output of above code will infinite loop.

Unknown said...

a question in c program

main()
{
int i=5;
printf("%d%d%d%d",i++,i--,++i,--i,i);
}
ans:45545
but how

Praveen Pandey said...

main()
{
int i=5;
printf("%d%d%d%d",i++,i--,++i,--i,i);
}

when we run this program comiler solve this left to right firstly
1)i=5
2)--i=4
3)++i=5
4)i--=5
5)i++=4

output is 45545

ANAND said...

The out put for ur program is syntax error as u have forget to close the brace for printf statement....
This is the write program

int main()
{
printf("%d",printf("pradeep"));
}
output:pradeep7

born to be famous said...

hello friends
i dont know keyword static in c. what is meaning of static variable.
please explain it.

mayank said...

the questions are good infact the hard work is really showing up in solutions.. bookmarked it gona read all the site every bit of it

Unknown said...

I want know the complete use of each function of header file graphics.h & proces.h wih examples

my email is itengineerkuldeep@gmail.com

Anonymous said...

hi ra............ na batta......... how r u ........... i didn't understand these questions.............

archana said...

very nice questions with deeply explanation

Anonymous said...

plz..... add some tutorials on file handling in
c language

Naga said...

167 , 3 , 1

Unknown said...

How to be a proficient in c programming coding