Break is a simple statement. It only makes sense if it occurs in the body of a switch, do, while or for statements. When it is executed, the control flow jumps out of the loop when the condition met. If you use break, it will go out of the loop and executes the statements out …
Start reading C program to Implement BREAK StatementCategory: C Programs
include swap (int *, int *);int main(){int a, b;printf(“\nEnter value of a & b: “);scanf(“%d %d”, &a, &b);printf(“\nBefore Swapping:\n”);printf(“\na = %d\n\nb = %d\n”, a, b);swap(&a, &b);printf(“\nAfter Swapping:\n”);printf(“\na = %d\n\nb = %d”, a, b);return 0;}swap (int *x, int *y){int temp;temp = *x;*x = *y;*y = temp;} OUTPUT:Enter value of a & b: 10 20 Before Swapping: …
Start reading Swapping of Two Numbers Using Call By Reference in CProgram to Search an Element using BInary Search */ include /* Function Prototype Declaration */void binary_search(); /* Global Declaration of Variables */int a[50], n, item, loc, beg, mid, end, i; /* We used main() because it’s a C-Compiler.Use void main() or int main() if necessary */ main(){printf(“\nEnter size of an array: “);scanf(“%d”, &n); // Reading …
Start reading C Program to Implement BINARY SEARCHinclude main(){int n,i,sum;i=1,sum=0;printf(“Enter Maximum Value(n):”);scanf(“%d”,&n);while(i<=n){sum=sum+i*i;++i;}printf(“Sum of squares of numbers from 1 to n is :%d “,sum);}OUTPUT: Enter Maximum Value(n):5Sum of squares of numbers from 1 to n is :55
Start reading C Program for Sum of Squares of Numbers from 1 to ninclude main(){int num;printf(“Enter a Number to test ZERO or +ve or -ve :”);scanf(“%d”,&num);if(num==0)printf(“Entered Number is ZERO”);elseif(num>0)printf(“%d is a Positive Number”,num);elseprintf(“%d is a Negative Numbr”,num);}OUTPUT: Enter a Number to test ZERO or +ve or -ve :1010 is a Positive Number
Start reading C Program to Find Given Integer is Positive or Negativemain(){ int n, i; printf(“Enter an Integer Number to Find PRIME or Not : “); scanf(“%d”, &n); for(i=2; i<=n/2; ++i) { if(n%i==0) { break; } } if(i>n/2) printf(“%d is PRIME”,n); else printf(“%d is NOT PRIME”, n);} OUTPUT: Enter an Integer Number to Find PRIME or Not : 2323 is PRIME
Start reading C Program to Check Given Number is PRIME or Notinclude main(){int no, digit = 0, temp;printf(“Enter an Integer to check for Palindrome : “);scanf(“%d”,&no);temp = no;while( temp != 0 ){digit = digit * 10;digit = digit + temp%10;temp = temp/10;}if ( no == digit )printf(“\n %d is a Palindrome Number :)\n”, no);elseprintf(“\n %d is Not a Palindrome Number :(“, no);} OUTPUT: Enter an Integer …
Start reading C Program to Check Whether a Number is PALINDROME or NotFinding GCD and LCM include int main(){ int no1, no2, rem=0, n1,n2; printf(“Enter Two Non-Zero Integer Mumbers:”); scanf(“%d%d”,&no1,&no2); n1=no1; n2=no2; rem=no1%no2; while(rem != 0) { no1=no2; no2=rem; rem=no1%no2; } printf(“\n GCD of %d and %d is %d”, n1,n2,no2); printf(“\n LCM of %d and %d is %d”,n1,n2,(n1*n2)/no2); return 0;} OUTPUT: Enter Two Non-Zero Integer Mumbers:15 25GCD of 15 and 25 is 5LCM of 15 and 25 is 75
Start reading Finding GCD and LCM of Given Numbers using Cinclude struct student{char name[20];int rollno;float marks;};struct student s1[3];void main(){int i;printf(“Enter Name, RollNo, and Marks of Three Students:\n”);//Reading Student detailsfor(i=0; i<=2; i++)scanf(“%s %d %f”,&s1[i].name,&s1[i].rollno,&s1[i].marks); } OUTPUT:Enter Name, RollNo, and Marks of Three Students:John 123 88Ravi 256 97Raj 214 94Student Name Student Rollno Student Marks:John 123 88.00Ravi 256 97.00Raj 214 94.00
Start reading C Program to Implement Structure with Array/* Write C programs that use both recursive and non-recursive functionsTo solve Towers of Hanoi problem.*/ include include /* Non-Recursive Function/ void hanoiNonRecursion(int num,char sndl,char indl,char dndl) { char stkn[50],stksndl[50],stkindl[50],stkdndl[50],stkadd[50],temp; int top,add; top=NULL; one: if(num==1) { printf(“\nMove top disk from needle %c to needle %c “,sndl,dndl); goto four; } two: top=top+1; stkn[top]=num; stksndl[top]=sndl; stkindl[top]=indl; stkdndl[top]=dndl; …
Start reading C Program to Solve Tower of Hanoi Problem Using Recursive and Non-Recursive