Programming For Problem Solving Assignment-1
Programming For Problem Solving Assignment-1
#include <stdio.h>
void main()
int x = 5;
if (x < 1)
printf("hello");
if (x == 5)
printf("hi");
else
printf("no");
a) hi
b) hello
c) no
d) error
#include <stdio.h>
int x;
void main()
if (x)
printf("hi");
else
a) hi
b) how are you
c) compile time error
d) error
#include <stdio.h>
void main()
int x = 5;
if (true);
printf("hello");
#include <stdio.h>
void main()
int x = 0;
if (x == 0)
printf("hi");
else
printf("how are u");
printf("hello");
a) hi
b) how are you
c) hello
d) hihello
#include <stdio.h>
void main()
int x = 5;
if (x < 1);
printf("Hello");
a) Nothing
b) Run time error
c) Hello
d) Varies
#include <stdio.h>
void main()
double ch;
scanf("%lf", &ch);
switch (ch)
case 1:
printf("1");
break;
case 2:
printf("2");
break;
7. What will be the output of the following C code? (Assuming that we have
entered the value 1 in the standard input)
#include <stdio.h>
void main()
char *ch;
scanf("%s", ch);
switch (ch)
case "1":
printf("1");
break;
case "2":
printf("2");
break;
a) 1
b) 2
c) Compile time error
d) No Compile time error
#include <stdio.h>
void main()
int ch;
scanf("%d", &ch);
switch (ch)
case 1:
printf("1\n");
default:
printf("2\n");
a) 1
b) 2
c) 1 2
d) Run time error
#include <stdio.h>
void main()
int ch;
scanf("%d", &ch);
switch (ch)
case 1:
printf("1\n");
break;
printf("Hi");
default:
printf("2\n");
a) 1
b) Hi 2
c) Run time error
d) 2
#include <stdio.h>
void main()
{
int ch;
scanf("%d", &ch);
switch (ch, ch + 1)
case 1:
printf("1\n");
break;
case 2:
printf("2");
break;
a) 1
b) 2
c) 3
d) Run time error