C Expressions and Control Flow questions

Q27

GATE CS 2026 CS-1C ProgrammingMSQ1 mark
Consider the following C statements:
char *str1 = "Hello; /* Statement S1 */
char *str2 = "Hello;"; /* Statement S2 */
int *str3 = "Hello"; /* Statement S3 */
Which of the following options is/are correct?
More than one option can be correct.
Show answer without attempting

Answer: C

Q34

GATE CS 2026 CS-1C ProgrammingNAT1 mark
Consider the following program in C:
#include <stdio.h>

void func(int i, int j) {
 if(i < j) {
 int i = 0;
 while (i < 10) {
 j += 2;
 i++;
 }
 }
 printf("%d", i);
}

int main() {
 int i = 9, j = 10;
 func(i, j);
 return 0;
}
The output of the program is _________. (answer in integer)
Note: Assume that the program compiles and runs successfully.
Show answer without attempting

Answer: 9

Q19

GATE CS 2026 CS-2C ProgrammingMCQ1 mark−1/3 if wrong
Consider the following three ANSI-C programs, P1, P2, and P3.
/* P1 */
#include <stdio.h>
int a=5;
int main(){
 int a=7;
 return(0);
}
/* P2 */
#include <stdio.h>
int main(){
 int a=5;
 int a=7;
 return(0);
}
/* P3 */
#include <stdio.h>
int main(){
 int a=5;
 float a=7;
 return(0);
}
Which one of the following statements is true?
Show answer without attempting

Answer: A

0/30 correct0 marks

Related topics in C Programming