443 views
1 votes
1 votes
int main()
{
    int a[30];
    printf("enter string:");
    scanf("%s",a);
    printf("%c\n",a[2]);

}

take a string "123456" tell o/p

2 Answers

2 votes
2 votes
In this program u r entering 123456 as input.

But scanf is not storing the input value

So, output of printf will be empty
0 votes
0 votes
please make me correct , if i am wrong

 

3 rd statement ,  scanf,

compilation problem because format specifier of string (%s) except only char values , but here no char pointer is defined ,

Related questions

0 votes
0 votes
1 answer
1
Debargha Mitra Roy asked 2 days ago
42 views
#include <stdio.h int main() { int a[3] = {1, 3, 5, 7, 9, 11}; int *ptr = a[0]; ptr += sizeof(int); printf("%d", *ptr); return 0; }(Assume size of int to be $2$ bytes.)T...
2 votes
2 votes
1 answer
2
1 votes
1 votes
1 answer
3
Sparsh-NJ asked Jul 15, 2023
377 views
Can an array store elements of different storage classes?