0% found this document useful (0 votes)
73 views6 pages

Quiz About C Macro & Preprocessor

The document contains a series of C programming questions focusing on macros and preprocessor directives, each accompanied by multiple-choice answers. It includes code snippets and asks for the output or behavior of the code, testing the reader's understanding of C macros. The questions cover various aspects of macros, including their definition, usage, and potential errors.

Uploaded by

chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views6 pages

Quiz About C Macro & Preprocessor

The document contains a series of C programming questions focusing on macros and preprocessor directives, each accompanied by multiple-choice answers. It includes code snippets and asks for the output or behavior of the code, testing the reader's understanding of C macros. The questions cover various aspects of macros, including their definition, usage, and potential errors.

Uploaded by

chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Tutorials

Search... Sign In
Practice
Jobs
DSA Practice Problems C C++ Java Python JavaScript Data Science Machine Learning Courses Linux DevOps SQL Web Develop

C Macro & Preprocessor


Last Updated : Mar 18, 2024 Discuss

Question 1

#include <stdio.h>
#define PRINT(i, limit) do \\
{ \\
if (i++ < limit) \\
{ \\
printf("GeeksQuiz\\n"); \\
continue; \\
} \\
}while(1)

int main()
{
PRINT(0, 3);
return 0;
}

How many times GeeksQuiz is printed in the above program?

A 1

B 3

C 4

D Compile-time error

Discuss it

Question 2

What is the output of following program?

#include <stdio.h>
#define macro(n, a, i, m) m##a##i##n
#define MAIN macro(n, a, i, m)

int MAIN()
{
printf("GeeksQuiz");
return 0;
}

A Compiler Error

B GeeksQuiz

C MAIN

D main
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
Got It !
Discuss itacknowledge that you have read and understood our Cookie Policy & Privacy Policy
Question 3

#include <stdio.h>
#define X 3
#if !X
printf("Geeks");
#else
printf("Quiz");

#endif
int main()
{
return 0;
}

A Geeks

B Quiz

C Compiler Error

D Runtime Error

Discuss it

Question 4

#include <stdio.h>
#define ISEQUAL(X, Y) X == Y
int main()
{
#if ISEQUAL(X, 0)
printf("Geeks");
#else
printf("Quiz");
#endif
return 0;
}

Output of the above program?

A Geeks

B Quiz

C Any of Geeks or Quiz

D Compile time error

Discuss it

Question 5

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
#include <stdio.h>
#define square(x) x*x
int main()
{
int x;
x = 36/square(6);
printf("%d", x);
return 0;
}

A 1

B 36

C 0

D Compiler Error

Discuss it

Question 6

Output?

# include <stdio.h>
# define scanf "%s Geeks Quiz "
int main()
{
printf(scanf, scanf);
return 0;
}

A Compiler Error

B %s Geeks Quiz

C Geeks Quiz

D %s Geeks Quiz Geeks Quiz

Discuss it

Question 7

#include <stdio.h>
#define a 10
int main()
{
printf("%d ",a);

#define a 50

printf("%d ",a);
return 0;
}

A Compiler Error
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
B 10acknowledge
50 that you have read and understood our Cookie Policy & Privacy Policy
C 50 50

D 10 10

Discuss it

Question 8

Output?

#include<stdio.h>
#define f(g,g2) g##g2
int main()
{
int var12 = 100;
printf("%d", f(var,12));
return 0;
}

A 100

B Compiler Error

C 0

D 1

Discuss it

Question 9

Predict the output of following program?

#include <stdio.h>
#define MAX 1000
int main()
{
int MAX = 100;
printf("%d ", MAX);
return 0;
}

A 1000

B 100

C Compiler Error

D Garbage Value

Discuss it

Question 10
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Output of following C program?
#include<stdio.h>
#define max abc
#define abc 100

int main()
{
printf("maximum is %d", max);
return 0;
}

A maximum is 100

B abcimum is 100

C 100imum is 100

D abcimum is abc

Discuss it

Tags: C Quiz

There are 21 questions to complete.

Take a part in the ongoing discussion View All Discussion

Company Explore Tutorials DSA Data Science & Web


About Us Job-A-Thon Python Data Structures ML Technologies
Corporate & Communications Legal Offline Java Algorithms Data Science With HTML
Address: Privacy Policy Classroom C++ DSA for Python CSS
Careers Program PHP Beginners
A-143, 7th Floor, Machine Learning JavaScript
Sovereign Corporate In Media DSA in GoLang Basic DSA ML Maths TypeScript
Tower, Sector- 136, Noida, Contact Us JAVA/C++ SQL Problems Data Visualisation ReactJS
Uttar Pradesh (201305) Corporate Master R Language DSA Roadmap Pandas NextJS
Solution System Android DSA Interview
Registered Address: NumPy NodeJs
Campus Design Questions
K 061, Tower K, Gulshan NLP Bootstrap
Training Master CP Competitive
Vivante Apartment, Sector Deep Learning Tailwind CSS
137, Noida, Gautam Buddh Program Videos Programming
Nagar, Uttar Pradesh,
201305 Python Computer DevOps System School Databases
Tutorial Science Git Design Subjects SQL

Python GATE CS AWS High Level Mathematics MYSQL

Examples Notes Docker Design Physics PostgreSQL

Django Operating Kubernetes Low Level Chemistry PL/SQL

Tutorial Systems Azure Design Biology MongoDB

Python Computer GCP UML Diagrams Social Science

Projects Network DevOps Interview Guide English Grammar


Advertise with us Database Roadmap
Python Design Patterns
Tkinter Management OOAD
Web Scraping System System Design
Software
We use cookies to ensure you have OpenCV
the best browsing experience on our website. By usingBootcamp
our site, you
Tutorial Engineering
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Python Digital Logic Interview
Interview Design Questions
Question Engineering
Maths
Preparation More Courses Programming Clouds/Devops GATE 2026
Corner Tutorials IBM Languages DevOps GATE CS Rank
Certification C Programming Engineering Booster
Company- Software
Courses with Data AWS Solutions GATE DA Rank
Wise Development
DSA and Structures Architect Booster
Recruitment Software
Placements C++ Certification GATE CS & IT
Process Testing
Web Programming Salesforce Course - 2026
Aptitude Product
Development Course Certified GATE DA
Preparation Management
Data Science Java Administrator Course 2026
Puzzles Project
Programming Programming Course GATE Rank
Company- Management
Languages Course Predictor
Wise Linux
DevOps & Python Full
Preparation Excel
Cloud Course
All Cheat
Sheets

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy

You might also like