C Typedef - Aptitude Questions and Answers

C programming Typedef Aptitude Questions and Answers: In this section you will find C Aptitude Questions and Answers on typedef topics, defining/changing name of any data type, using and accessing the typedef values.

1) What will be the output of following program ?
#include < stdio.h >
int main()
{
	typedef int AAA,BBB,CCC,DDD;
	AAA aaa=10;
	BBB bbb=20;
	CCC ccc=30;
	DDD ddd=40;
	printf("%d,%d,%d,%d",aaa,bbb,ccc,ddd);
	return 0;
}
  1. Error
  2. 10,10,10,10
  3. 10,20,30,40
  4. AAA,BBB,CCC,DDD

2) What will be the output of following program?
#include < stdio.h >
int main()
{
	typedef auto int AI;
	AI var=100;
	printf("var=%d",var);
	return 0;
}
  1. var=100
  2. var=AI
  3. var=0
  4. Error


3) What will be the output of following program?
#include < stdio.h >
int main()
{
	typedef char* string;
	string myName="ABCDEFG";
	printf("myName=%s (size=%d)",myName,sizeof(myName));
	return 0;
}
  1. myName=ABCDEFG (size=7)
  2. Error
  3. myName=ABCDEFG (size=4)
  4. myName=ABCDEFG (size=8)

4) What will be the output of following program?
#include < stdio.h >
int main()
{
	typedef struct 
	{
		int	 empid;
		int  bsal;
	}EMP;
	EMP E={10012,15100};
	printf("%d,%d",E.empid,E.bsal);
	return 0;
}
  1. 10012,15100
  2. 0,0
  3. ERROR
  4. 10012,10012





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.