Practice 1
Practice 1
a. #include<stdio.h>
int main()
{
int a;
a+=1;
return 0;
}
b. #include<stdio.h>
int main()
{
int a=1;
int b=a/0; return 0; }
9. What will be the value of x here? Give your reasoning.
int x = 10+20*10-(5*3)
10. Write a C program to calculate the following equation for any value of x.
11. Write a C program using switch-case that will read the month number and
display the month name.
12. Write a C program that will change the values of x, y, z in cyclic order.
X -> Y -> Z ->X
13. Rewrite the following code using the if else statement.
#include<stdio.h>
int main()
{
int i;
scanf("%d",&i);
switch(i){
case 1:
printf("one");
break;
case 2:
printf("two");
break;
case 3:
printf("three");
break;
default:
printf("Unrecognized Number");
}
return 0;
}
14. What is the difference between do…while and while loop? What will be the
output of the following code?
int i=0;
do{
printf("%d",i);
i- - ;
}while(i>0);
15. What is the use of break and continue keywords in C? What will be the output
of the following code?
#include<stdio.h>
int main()
{
int i;
for(i=1; i<20; i++)
{
printf(“%d”, i);
if(i==10) break;
}
return 0;
}
}
19. Write code for the following pattern: