July 5, 2021 in C and CPP
Consider the following program,
1.4 Consider the following program,
main( )
{
int x = 49;
for(;x;)
x--;
printf(“%d\n”, x);
}
the output of the program will be
A) 49
B) 0
C) -49
D) none of the above
July 5, 2021 in C and CPP
1.4 Consider the following program,
main( )
{
int x = 49;
for(;x;)
x--;
printf(“%d\n”, x);
}
the output of the program will be
A) 49
B) 0
C) -49
D) none of the above
July 5, 2021 in C and CPP
1.3 What is the missing statement in the following function which copies string x into string y
void strcpy( char *x, char *y)
{
while (*y != ‘\0’)
………………… /* missing stament */
*x = ‘\0’;
}
A) x = y
B) *x++ = *y++
C) (*x)++ = (*y)++
D) none of the above
July 5, 2021 in C and CPP
Given the following code fragment:
int main(void)
{
int raw[20], i, sum=0;
int *p = raw;
for (i=0; i < 20; i++)
*(p+i) = I;
for(i=0; i < 20; I += sizeof(int))
sum += *(p+i)
printf(“sum = %d\n”, sum);
return();
}
What will be the result of execution?
A) sum = 10
B) sum = 40
C) sum = 60
D) sum = 190
July 5, 2021 in C and CPP
1.1 Given the following code fragment:
void main(void)
{
char x = ‘\0’;
char n = ‘N’;
printf(“%u” ”%s\n”, &n, &n);
}
What will be the result of execution?
A) ddddd N ( where d represents any digit)
B) 78 N
C) 78 garbage
D) compilation error
July 5, 2021 in C and CPP
b) It is said that “C is a middle level language and is good for system level programming.”
Describe three facilities available in ‘C’ which support this statement.
July 5, 2021 in C and CPP
a) Draw a flowchart and then write a C program to enter the roll number and marks of any
three subjects of few students from the keyboard and write to a file.
July 5, 2021 in C and CPP
b) Develop a flowchart and logic to implement the stack data structure using link list.
July 5, 2021 in C and CPP
a) Explain the difference between parameter passing mechanism “Call by value” and “Call
by reference”. Which is more efficient and why?
July 5, 2021 in C and CPP
7. Develop a flowchart and then write a C program to find the occurrence (single or
multiple) of a substring in a given string. The substring and string are entered by the
user. Also point out the location at which the substring occurs.
July 5, 2021 in C and CPP
6. Write an algorithm and then develop a program to evaluate the roots of a quadratic
equation. Define and use a function cal_roots() to calculate the roots such that roots are
also available in calling function i.e. use pointers.