Guess The Output


Here are some C and C++ Coding. You can find the output of the following.

 

1. #include<iostream.h>

#include<conio.h>

void add(int , int);

void main()

{

int a,b,c;

cout<<“\nEnter two numbers: “;

cin>>a>>b;

add(a,b);

void add(int a,int b)

{

int d=a+b;

cout<<“Addition of two numbers is “<<d;

}

getch();

}

 

2. #include<stdio.h>

#include<conio.h>

void main()

{

int far*ptr1, *ptr2;

clrscr();

printf(“Size of Pointer1: %d\n Size of Pointer2: %d”,sizeof(ptr1),sizeof(ptr2));

getch();

}

 

3. #include<iostream.h>

#include<conio.h>

void main()

{

unsigned int i=50;

int j=-2;

clrscr();

if(i<j)

cout<<j<<” is greater”;

else

cout<<i<<” is greater”;

getch();

}

 

4.#include <iostream.h>

void main()

{

int x,y;

x = 2;

y = ++x *++x;

cout(“Value of x = %d and Value of y = %d\n”,x,y);

}

 

5. #include<stdio.h>

#include<conio.h>

#define AND &&

#define cond (a>25 AND a<50)

void main()

{

int a=30;

if(cond)

printf(“Within Range”);

else

printf(“Out of range”);

getch();

}

 

Outputs

1. It shows “declaration syntax error“. Since the main function can not have the function definition.

2.  Size of Pointer1: 4

Size of Pointer2: 2

The far pointer is special pointer, which holds 4 bytes.

3. -2 is greater.

Since the int type is promoted to unsigned int, -2 becomes 65534. Which is obviously greater than 12.

4.  Value of x is 4 and value of y is 16

5.  Within Range.

Tags: , ,

You may also like

LEAVE A COMMENT

Welcome To TechTwinklers!

Tech Twinklers is a Tech Blog run by Students with an aspiring enthusiasm in Technology and Gaming. This Blog will bring News about the Modern Technology, Educational Advances, Campus Interviews, etc. So make sure you subscribe to our blog because we don't want you to miss a thing that is posted here..

We're on Facebook!