728by90ad
Pointers - Point Out Correct Statements Multiple Questions and Answers.
Exercise Questions ::
Pointers
6. | Which statement will you add to the following program to ensure that the program outputs "PakMcqs" on execution? |
|
#include<stdio.h>
int main()
{
char s[] = "PakMcqs";
char t[25];
char *ps, *pt;
ps = s;
pt = t;
while(*ps)
*pt++ = *ps++;
printf("%s\n", t);
return 0;
}
|
| A. | *pt=''; |
| B. | pt='\0'; |
| C. | pt='\n'; |
| D. | *pt='\0'; |
|
|
Published by:Michael Daani
7. | In the following program add a statement in the function fact() such that the factorial gets stored in j? |
|
#include<stdio.h>
void fact(int*);
int main()
{
int i=5;
fact(&i);
printf("%d\n", i);
return 0;
}
void fact(int *j)
{
static int s=1;
if(*j!=0)
{
s = s**j;
*j = *j-1;
fact(j);
}
}
|
| A. | j=s; |
| B. | *j=s; |
| C. | *j=&s; |
| D. | &j=s; |
|
|
Published by:Michael Daani
«