UrbanPro
true

Learn C++ Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Predict the Output of C Questions based on Recursion and Macro

Yashvardhan Soni
19/10/2018 0 0

#include<stdio.h>
void k(unsigned int i,unsigned int j){
static char x[]="0123456789ABCDEF";
if(i>=j) k(i/j,j);
putchar(x[i%j]);}
void main(){
k(20,12);} 

 

___________________________________________

 

#include<stdio.h>
int test(int a,int b){
if(a==b) return 1;
else if(a>b)return 0;
else return(a+test(a+1,b));
}
main(){
int x;
x=test(0,3);
printf("%d",x);} 

 

____________________________________________________________

 

#include<stdio.h>
main(){
int x(int,int);
printf("%d\n", x(1,1));}
int x(int m,int n){
if(m==0)return n+1;
if(m>=1&&n==0)
return x(m-1,1);
else
return x(m-1,x(m,n-1));} 

______________________________________________________________________


#include<stdio.h>
int f(char *p);
main()
{
char *p="hello";
f(p);
}
int f(char *p)
{
if(*p?f(++p):1)
printf("%c", *(--p));
return 1;
}

_________________________________________________________________
#include<stdio.h>
#define MAIN() main()
#define mAIN() Main()
int MaIn() {printf("Main ");}
int mAIN() {printf("main ");}
int MAIN() {printf("MAIN "); mAIN();}

___________________________________________________________

 

#include<stdio.h>
void foo(int n){
int m=1;
if(n){m++;
foo(n+1);}
m++;printf("m=%d, n=%d\n", m, n);
}

main(){
foo(-3);}
---------------------------------------------------------------------------------------------------------#include<stdio.h>
main(){
int For;
for(For=0;For<=6;For++)
for(For=0;For<=3;For++)
for(For=0;For<=5;For++)
printf("%d\n", For);
printf("%d\n", For);}

 

_________________________________________________________________
#include<stdio.h>
#define max(a,b) a>b?a:b
main(){
int m,n;
m=3+max(2,3);
n=2*max(3,2);
printf("%d %d", m, n);}

________________________________________________________________
#include<stdio.h>
int zap(int n){
if(n<=1)
return 1;
else
return(zap(n-3)+zap(n-1));}
main(){
printf("%d\n",zap(6));} 

_______________________________________________________________
#include<stdio.h>
#define ceil(x, y) (x+y-1)/y

main(){
int a,b,c;
b=1;c=1;
a=ceil(b&c, sizeof(int));
printf("%d \n", a);}
_________ _______________________________________________
#include<stdio.h>
void revs(char *c) {
if(*c!='\0'){
c++;revs(c++);
printf("%c",*c);}}
main(){
char c[10]="hello";
int n;
n=strlen(c);
revs(c);}
________________________________________________________________

0 Dislike
Follow 3

Please Enter a comment

Submit

Other Lessons for You

C, C++, JAVA Tutor
* Program to swap two numbers using a temporary variable with each statement explained with comments * #include // headerfile for cout statement using namespace std; //...

Importance Of Function Prototype In C
Function prototype tells compiler about number of parameters function takes, data-types of parameters and return type of function. By using this information, compiler cross checks function parameters and...

Magic in C=> OFFSET OF MACRO in C [offsetof(TYPE, MEMBER)]
Here I am going to discuss an exciting macro in C. It will give you offset of a member within a structure. NULL or 0 address is typecasted to TYPE first. It won't result in segmentation fault as we are...

C Programming Language Basics - Easy way to learn
Computer - OverviewTodays world is an information-rich world and it has become a necessity for everyone to know about computers. A computer is an electronic data processing device, which accepts and stores...

Definite book guides for C++
This post attempts to collect the few pearls among the dozens of bad C++ books. Unlike many other programming languages, which are often picked up on the go from tutorials found on the internet, only...
X

Looking for C++ Language Classes?

The best tutors for C++ Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C++ Language with the Best Tutors

The best Tutors for C++ Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more