You are here:

C/c language

Advertisement


Question
Sir i newly joined C language course my preceptor give me assignment of *pointer. Here beneath i mentioned my project for your reference & record please advice where i am wrong.

#include<stdio.h>
#include<conio.h>

int main()

{

int a=5;
int b=9;
int max;


int*g;
g=&a;

int*h
h=&b
if (g<h);
{
printf("the max value %d",&a);
}
else
{
printf("the max value %d,&b);

getch ();
return 0'

Answer
You are passing the wrong type to printf. The code you have written will cause the following issue:

format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’

Please try: printf("the max value %d\n",a);

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tony Nazzal

Expertise

I will answer any c language programming and syntax questions.

Experience

I have almost a decade of c programming experience.

Education/Credentials
I have a bachelor of science degree and several years of industry experience.

©2016 About.com. All rights reserved.