What is the output for the program given below
typedef enum errorType{warning, error,
exception,}error;
main()
{
error g1;
g1=1;
printf("%d",g1);
}
Answer / susie
Answer :
Compiler error: Multiple declaration for error
Explanation
The name error is used in the two meanings. One means
that it is a enumerator constant with value 1. The another
use is that it is a type name (due to typedef) for enum
errorType. Given a situation the compiler cannot distinguish
the meaning of error to know in what sense the error is used:
error g1;
g1=error;
// which error it refers in each case?
When the compiler can distinguish between usages then
it will not issue error (in pure technical terms, names can
only be overloaded in different namespaces).
Note: the extra comma in the declaration,
enum errorType{warning, error, exception,}
is not an error. An extra comma is valid and is provided
just for programmer’s convenience.
Is This Answer Correct ? | 6 Yes | 0 No |
struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); } a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above
hello sir,is there any function in C that can calculate number of digits in an int type variable,suppose:int a=123; 3 digits in a.what ll b answer?
Is it possible to print a name without using commas, double quotes,semi-colons?
main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }
program to Reverse a linked list
12 Answers Aricent, Microsoft, Ness Technologies,
void main() { int *i = 0x400; // i points to the address 400 *i = 0; // set the value of memory location pointed by i; }
main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); printf("%d %d", i, j); }
write a c program to Create a registration form application by taking the details like username, address, phone number, email along with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 5 users and display the details. In place of password display “****”. (Use Structures).
0 Answers CDAC, College School Exams Tests,
#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }
What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }
What are the files which are automatically opened when a C file is executed?
main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }