Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

C PROGRAM QUESTIONS : PART 21

What will be the output of the program ?
#include<stdio.h>
#include<string.h>
int main()
{
    int i, n;
    char *x="Alice";
    n = strlen(x);
    *x = x[n];
    for(i=0; i<=n; i++)
    {
        printf("%s ", x);
        x++;
    }
    printf("", x);
    return 0;
}

Alice
ecilA
Alice lice ice ce e
lice ice ce e
SHOW ANSWER

What will be the output of the program ?
#include<stdio.h>

int main()
{
    int i, a[] = {2, 4, 6, 8, 10};
    change(a, 5);
    for(i=0; i<=4; i++)
        printf("%d, ", a[i]);
    return 0;
}
change(int *b, int n)
{
    int i;
    for(i=0; i<n; i++)
        *(b+1) = *(b+i)+5;
}

7, 9, 11, 13, 15
2, 15, 6, 8, 10
2 4 6 8 10
3, 1, -1, -3, -5
SHOW ANSWER

If the size of integer is 4bytes, What will be the output of the program?
#include<stdio.h>
int main()
{
    int arr[] = {12, 13, 14, 15, 16};
    printf("%d, %d, %d", sizeof(arr), sizeof(*arr), sizeof(arr[0]));
    return 0;
}

10, 2, 4
20, 4, 4
16, 2, 2
20, 2, 2
SHOW ANSWER

Which of the following function sets first n characters of a string to a given character?

strinit()

strnset()

strset()

strcset()

SHOW ANSWER

What will be the output of the program ?

#include<stdio.h>

#include<string.h>

int main()

{

    char str1[20] = "Hello", str2[20] = " World";

    printf("%s", strcpy(str2, strcat(str1, str2)));

    return 0;

}

Hello

World

Hello World

WorldHello

SHOW ANSWER

Which of the following statements are correct about the program below?

#include<stdio.h>

int main()

{

    char str[20], *s;

    printf("Enter a string");

    scanf("%s", str);

    s=str;

    while(*s != '')

    {

        if(*s >= 97 && *s <= 122)

            *s = *s-32;

        s++;

    }

    printf("%s",str);

    return 0;

}

The code converts a string in to an integer

The code converts lower case character to upper case

The code converts upper case character to lower case

Error in code

SHOW ANSWER

Will the program compile successfully?

#include<stdio.h>

int main()

{

    char a[] = "Astiwz";

    char *p = "QUIZ";

    a = "QUIZ";

    p = "Astiwz";

    printf("%s %s", a, p);

    return 0;

}

Yes

No

SHOW ANSWER

The library function used to reverse a string is

strstr()

strrev()

revstr()

strreverse()

SHOW ANSWER

What will be the output of the program ?

#include<stdio.h>

 

int main()

{

    char p[] = "%d";

    p[1] = 'c';

    printf(p, 65);

    return 0;

}

A

a

c

65

SHOW ANSWER

Which of the following statements are correct about the below declarations?

char *p = "Sanjay";

char a[] = "Sanjay";

1:There is no difference in the declarations and both serve the same purpose.

2:p is a non-const pointer pointing to a non-const string, whereas a is a const pointer pointing to a non-const pointer.

3:The pointer p can be modified to point to another string, whereas the individual characters within array a can be changed.

4:In both cases the '' will be added at the end of the string "Sanjay".

1, 2

2, 3, 4

3, 4

2, 3

SHOW ANSWER

For the following statements will arr[3] and ptr[3] fetch the same character?

char arr[] = "ASTIWZ";

char *ptr = "ASTIWZ";

Yes

No

SHOW ANSWER

If the two strings are identical, then strcmp() function returns

-1

1

0

Yes

SHOW ANSWER

What will be the output of the program ?

#include<stdio.h>

#include<string.h>

int main()

{

    printf("%d", strlen("123456"));

    return 0;

}

6

12

7

2

SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in