Final Paper PF
Final Paper PF
3. An expression contains relational, assignment and arithmetic operators. If Parenthesis are not present, the
order will be:
a) Assignment, arithmetic, relational c) Assignment, relational, arithmetic
b) Relational, arithmetic, assignment d) Arithmetic, relational, assignment
#include <stdio.h> a) 10 10 10
int main()
{ b) 100xaa54f10
int x = 10, *y, **z; c) Run time error
d) No Output
y = &x;
z = &y;
printf("%d %d %d", *y, **z, *(*z));
}
3. main() 4. main()
{ {
char s[ ]="man"; int const * p=5;
int i; printf("%d",++(*p));
for(i=0;s[ i ];i++) }
printf("%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
5. main() 6. int main()
{ {
int array[10] = {3, 0, 8, 1, 12, 8, 9, 2, 13, 10}; int arri[] = {1, 2 ,3};
int x, y, z; int *ptri = arri;
x = ++array[2]; char arrc[] = {1, 2 ,3};
y = array[2]++; char *ptrc = arrc;
z = array[x++]; printf("sizeof arri[] = %d ", sizeof(arri));
printf("sizeof ptri = %d ", sizeof(ptri));
} printf("sizeof arrc[] = %d ", sizeof(arrc));
printf("sizeof ptrc = %d ", sizeof(ptrc)); }
7. main() 8. main()
{
{
int val = 1;
char str1[] = "Hello. How are you?";
char str2[21];
do {
int pos;
val++;
for(pos=0; pos<21; pos++);
++val;
{
} while (val++ > 25);
str2[pos] = str1[pos];
printf("%d\n", val);}
}
printf("str1: %s, str2: %s", str1, str2); }
9. main()
10. main()
{
{
char *_ptr = malloc(100);
int x = 5, y = 10;
if(_ptr!=NULL)
int const *p = &x;
free(_ptr);
*p = 15;
free(_ptr); }
printf("%d", x); }
Question 3. Ali is playing a game of cards. This is a special type of cards in which cards are a 3 digit number
(i.e. 100 - 999). He has to sort the cards in ascending order. However, sorting will be done on the sum of the
digits. Make a c program to sort his cards, take user input for number of cards. Taking input of cards number
should be a function named get_data(). Sorting should be another function sort() and displaying the final
result should be another function display(). (20 marks)
Required: You are required to write a code for the following operations: (5 marks each = 20 marks)
a. Reverse the given string without using any additional array or even an extra variable. The resultant
.
b.
c. Wildcard Pattern Matching: Given a string and a pattern containing wildcard characters, i.e., * and ? ,
where ? Can match to any single character in the string and * can match to any number of characters
including zero characters, design an efficient algorithm to check if the pattern matches with the
complete string or not.
Input: string = pattern = Input: string = pattern =
Output: Match
Input:
Output: