Posts

Showing posts from December, 2022

Jump Statements in C – break, continue, goto, return

Image
Jump Statement  makes the control jump to another section of the program unconditionally when encountered. It is usually used to terminate the  loop   or  switch-case   instantly. It is also used to escape the execution of a section of the program. ·         Break ·         Continue ·         Goto ·         Return 1. Break Jump Statement A  break  statement is used to terminate the execution of the rest of the block where it is present and takes the control out of the block to the next statement. It is mostly used in loops and switch-case to bypass the rest of the statement and take the control to the end of the loop. The use of the  break  keyword in switch-case has been explained in the previous tutorial  Switch – Control Statement . Another point to be taken into consideration is that the  break  statement when used in nested loops only terminates the inner loop where it is used and not any of the outer loops. Example #include <stdio.h> int main ()   {   int i;    for

MINI TEST, MANIT Bhopal Dec 2022

Image
  Question 1: Write a program that prints the word addition as "MANIT" using the ASCII value of individual characters. Code #include <stdio.h> int main() {     char a='M', b='A', c='N',d='I',e='T';     int sum;     sum = a+b+c+d+e;     printf("Sum of %c+%c+%c+%c+%c is %d"     ,a,b,c,d,e,sum);       return 0; } Output: Sum of M+A+N+I+T is 377   Question 2: Write a program to find MIN and MAX without using IF-ELSE and take three values from the user.   Code #include <stdio.h> main() {     int a, b, c, Max, Min ;       printf("Enter three numbers : ") ;       scanf("%d %d %d", &a, &b, &c) ;       Max = a > b ? (a > c ? a : c) : (b > c ? b : c) ;     Min = a < b ? (a < c ? a : c) : (b < c ? b : c) ;       printf("\nThe Biggest number is : %d \nThe Smallest number is : %d", Max, Min) ;