C

Ques:- main() { char *p1=”Name”; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf(“%sn”,p2); } what is the output?
Recent Answer : Added by DK BOSS On 2021-07-17 06:18:27:

it will print p2=Name

Ques:- which of the following statements is incorrect a.typedef struct new{ int n1; char n2; } DATA; b.typedef struct { int n3; char *n4; }ICE; c.typedef union { int n5; float n6; } UDT; d.#typedef union { int n7; float n8; } TUDAT;
Recent Answer : Added by Admin On 2020-05-17 11:16:29:

choice d.
Reason:
The macro sign # is not applicable here.
Syntactical error!

Ques:- int *a[5] refers to
Recent Answer : Added by Admin On 2020-05-17 11:16:26:

int *a[5] means that there are 5 integer pointers[which
store adresess of only integers] whose adresses are in
continous locations and each pointer name is accesed by *a
[0],*a[1]….*a[4].for example
a[0]=n means a[0] points to n, a[1]=p means a[1] points to
p.[where n and p are integers]Let the adress of n and p be
some 625 and 254 respectively. then a[0] will hold 625
whose adress is(assume)1000 and a[1]will hold 254 whose
adress is 1002.similarly the a[2] will hold some adress(if
u make it to point) with its adress 1004 and a[3] will hold
some others adress with its adress 1006 and a[4] will hold
some others adress with its adress 1008.

Ques:- find the output of the following program main() { int x=5, *p; p=&x; printf(“%d”,++*p); }
Recent Answer : Added by Admin On 2020-05-17 11:16:29:

6
becoz it(++*p) will evaluate like this-
1)
*(p)- gives value at this address that is 5
2)
now increment ++5
that is 6.

Ques:- consider the following C code main() { int i=3,x; while(i>0) { x=func(i); i–; } int func(int n) { static sum=0; sum=sum+n; return(sum); } the final value of x is
Recent Answer : Added by Admin On 2020-05-17 10:36:12:

Answer is 6;
Sum being the static variale will retain its value state
between he function calls.

Ques:- the format specified for hexa decimal is a.%d b.%o c.%x d.%u
Recent Answer : Added by Admin On 2020-05-17 11:16:28:

it is x for hexadecimal

Ques:- consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; case 3:sum*=2; break; default:sum=0;} if n=2, what is the value of sum a.0 b.6 c.3 d.none
Recent Answer : Added by Admin On 2020-05-17 10:36:10:

6

Ques:- # define prod(a,b)=a*b main() { int x=2; int y=3; printf(“%d”,prod(x+2,y-10)); } the output of the program is a.8 b.6 c.7 d.none
Recent Answer : Added by Admin On 2020-05-17 11:16:26:

It will lead to compilation error..
Note: # define prod(a,b)=a*b
‘=’ is not allowed with #define
regards,
Arun Raj

Ques:- pick out the odd one out of the following a.malloc() b.calloc() c.free() d.realloc()
Recent Answer : Added by Admin On 2020-05-17 11:16:27:

c.free()

Ques:- which of the following go out of the loopo if expn 2 becoming false a.while(expn 1){…if(expn 2)continue;} b.while(!expn 1){if(expn 2)continue;…} c.do{..if(expn 1)continue;..}while(expn 2); d.while(!expn 2){if(expn 1)continue;..}
Recent Answer : Added by Admin On 2020-05-17 11:16:28:

c) Since expn2 becoming false will terminate do-while loop.

Ques:- the operator for exponencation is a.** b.^ c.% d.not available
Recent Answer : Added by Admin On 2020-05-17 11:16:25:

d.not available is d right ans.

Ques:- how many times does the loop iterated ? for (i=0;i=10;i+=2) printf(“Hin”);
Recent Answer : Added by Admin On 2020-05-17 11:16:27:

infinite coz there is no condition to stop it

Ques:- what is y value of the code if input x=10 y=5; if (x==10) else if(x==9) elae y=8; a.9 b.8 c.6 d.7
Recent Answer : Added by Admin On 2020-05-17 10:36:15:

I’m getting “error C2181: illegal else without matching if”.
If that is corrected then the output will be y = 5.

Ques:- a=0; while(a
Recent Answer : Added by Admin On 2020-05-17 11:16:27:

Hello,
The answer is b.
a=0+1=1
a=1+1=2
a=2+1=3
a=3+1=4
a=4+1=5
While a variable is storing the 5 result a is nither less
then are equal to 5 hence the application will come out of
the loop.So while loop had run 5 times.

Ques:- what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){ case 4:a+=a*r; case 3:a+=a*r; case 2:a+=a*r; case 1:a+=a*r; } } a.computes simple interest for one year b.computes amount on compound interest for 1 to 4 years c.computes simple interest for four year d.computes compound interst for 1 year
Recent Answer : Added by DK BOSS On 2021-07-15 09:31:50:

if this function is called from within a loop with n=0 to n<4
then cases 1,2,3,4 in switch will be called one by one
as int a is static , first time it will be initialized with the value p but afterwords
its memory location will be updated every time the fun is called with the latest value of a calculated within the case
but r should be a float value
example:
main()
int p=100;
float r=0.10;
{
for(n=1;na=100+100*.1
a=110

second iteration
a=110;
n=2
case(2)
a=a+a*r=>a=110+110*.1
a=121

third iteration
a=121
n=3
case(3)
a=a+a*r=> a=121+121*.1
a=133.1

fourth iteration
a=133
n=4
case(4)
a=133+133*.1
a=146

in this way, we can see this is the amount for compound interest for 1-4 years

Ques:- Struct(s) { int a; long b; } Union (u) {int a; long b; } Print sizeof(s)and sizeof(u) if sizeof(int)=4 and sizeof(long)=4
Recent Answer : Added by Admin On 2020-05-17 10:36:08:

Size fo strucure wil be the total bytes of the datatypes
inside it..
so,4+4=8;
For unions the size wi be the size of the datatype whose
memory is high,.
so,its 4,.

Ques:- What will be the result of the following program? main() { char p[]=”String”; int x=0; if(p==”String”) { printf(“Pass 1”); if(p[sizeof(p)-2]==’g’) printf(“Pass 2”); else printf(“Fail 2”); } else { printf(“Fail 1”); if(p[sizeof(p)-2]==’g’) printf(“Pass 2”); else printf(“Fail 2”); } } a) Pass 1, Pass 2 b) Fail 1, Fail 2 c) Pass 1, Fail 2 d) Fail 1, Pass 2 e) syntax error during compilation
Recent Answer : Added by Admin On 2020-05-17 10:36:20:

d) Fail 1, Pass 2

Ques:- What will be result of the following program? void myalloc(char *x, int n) { x= (char *)malloc(n*sizeof(char)); memset(x,,n*sizeof(char)); } main() { char *g=”String”; myalloc(g,20); strcpy(g,”Oldstring”); printf(“The string is %s”,g); } a) The string is : String b) Run time error/Core dump c) The string is : Oldstring d) Syntax error during compilation e) None of these
Recent Answer : Added by Admin On 2020-05-17 10:36:25:

a)the string is string

Ques:- what will be the result of the following program ? char *gxxx() { static char xxx[1024]; return xxx; } main() { char *g=”string”; strcpy(gxxx(),g); g = gxxx(); strcpy(g,”oldstring”); printf(“The string is : %s”,gxxx()); } a) The string is : string b) The string is :Oldstring c) Run time error/Core dump d) Syntax error during compilation e) None of these
Recent Answer : Added by DK BOSS On 2021-07-15 05:26:15:

b) The string is :Oldstring
as per the question static variable memory is created for one time so it will return Oldstring

Ques:- In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf(“same”); else printf(“not same”); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT
Ques:- What is the result main() { char c=-64; int i=-32 unsigned int u =-16; if(c>i){ printf(“pass1,”); if(c
Recent Answer : Added by Admin On 2020-05-17 10:36:06:

Fail1, Pass2

Ques:- Result of the following program is main() { int i=0; for(i=0;i
Recent Answer : Added by Admin On 2020-05-17 10:36:10:

Answer is e), since opening and closing flower braces do
not match in numbers and default do not have colon
following it. Assuming switch(i) has an opening flower
brace and default has colon after it “switch(i) {, …
default: i+= 4;”answer would be d).
All cases will be fall-through including default:

Ques:- f(char *p) { p=(char *)malloc(sizeof(6)); strcpy(p,”HELLO”); } main() { char *p=”BYE”; f(p) printf(“%s”,p); } what is the output?
Recent Answer : Added by subham kumar On 2020-09-16 08:27:03:

How is the answer BYE?

Ques:- #include main() { char s1[]=”Ramco”; char s2[]=”Systems”; s1=s2; printf(“%s”,s1); } Find the output
Recent Answer : Added by Admin On 2020-05-17 10:36:01:

it will be an error as for as i know… since s1 is not a
pointer variable… but however array are implict
pointers…. here we cant assign the base address to
another arry which is capable of holding oly values not
addressses……………

Ques:- main() { char *ptr = “Ramco Systems”; (*ptr)++; printf(“%sn”,ptr); ptr++; printf(“%sn”,ptr); } Find the Outputs?
Recent Answer : Added by Admin On 2020-05-17 10:35:58:

Turbo c will give an answer
samco system
amco system
pointer ptr is at r
by(*ptr)++ we are incrementing it by one so we get s
by ptr ++ we are incrementing the addrestion of ptr so it
will give an output amco system;
but gcc compiler will not give any answer it will print
segmentation fault

Ques:- main() { int x=5; printf(“%d %d %dn”,x,x>2); }
Recent Answer : Added by Admin On 2020-05-17 10:35:56:

5,20,1

Ques:- main() { char *p1=”Name”; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf(“%sn”,p2); }
Recent Answer : Added by Admin On 2020-05-17 10:36:00:

the given program gives some meaningless output, with some
modification to the given program as
#include
#include
main()
{
char a[]=”ramesh”;
char *p1=”Name”;
char *p2=a;
while(*p2++=*p1++);/*copies contents of p1 to
p2*//* here it is not possible to use while(*a++=*p1++)
because a can not change its value*/
*p2=’’;
printf(“%sn”,a);
}
The output will be Name

Ques:- main() {char a[10]={1,2,3,4,5,6};int x; for(x=0;x
Recent Answer : Added by Admin On 2020-05-17 10:35:45:

it gives compilation error bcoz b is not defined

Ques:- main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(“%d %dn”,x,y); }
Recent Answer : Added by Admin On 2020-05-17 10:35:19:

57
94

Ques:- regarding the scope of the varibles;identify the incorrect statement: a.automatic variables are automatically initialised to 0 b.static variables are are automatically initialised to 0 c.the address of a register variable is not accessiable d.static variables cannot be initialised with any expression
Recent Answer : Added by Admin On 2020-05-17 10:35:54:

a

Scroll to top