int main(){int f1=0,f2=1,f3,i=3,len;printf(“enter length of the fibonacci series:”);scanf(“%d”,&len);printf(“%d\t%d”,f1,f2); // It prints the starting two valueswhile(i<=len) // checks the condition{f3=f1+f2; // performs add operation on previous two valuesprintf(“\t%d”,f3); // It prints from third value to given lengthf1=f2;f2=f3;i=i+1; // incrementing the i value by 1}return 0;} Output for Fibonacci Series Program enter length of the fibonacci series:100 …
Start reading C Program for Fibonacci Series using While LoopBlog
The following C program describes the sum of individual digits of a given positive integer. Example: 456 as 4+5+6 = 15 include include void main(){int n,sum=0;printf(“enter a +ve integer”); // enter a integer valuescanf(“%d”,&n);while(n>0) // checks the condition{sum=sum+n%10; // sum + remainder valuen=n/10; } OUTPUT: enter a +ve integer456 sum of individual digits of a …
Start reading C Program to Find Sum of Individual Digits of a Positive Integer Number/Prime factors for a number using c/ include include int main(){int num,i=1,j,k;//clrscr();printf(“\nEnter a number:”);/* enter a positive integer / scanf(“%d”,&num); while(i<=num) { k=0; if(num%i==0) // checks for factor { j=1; while(j<=i) { if(i%j==0) { k++; } j++; } if(k==2) / checks for prime factor */printf(“\n%d is a prime factor”,i);}i++;}getch();} OUTPUT for Prime Factors of a …
Start reading C Program to Find Prime Factors of a Given Positive NumberBit stuffing is a process of inserting an extra bit as 0, once the frame sequence encountered 5 consecutive 1’s.z include include int main(){int a[20],b[30],i,j,k,count,n;printf(“Enter frame size (Example: 8):”);scanf(“%d”,&n);printf(“Enter the frame in the form of 0 and 1 :”);for(i=0; i<n; i++)scanf(“%d”,&a[i]);i=0;count=1;j=0;while(i<n){if(a[i]==1){b[j]=a[i];for(k=i+1; a[k]==1 && k<n && count<5; k++){j++;b[j]=a[k];count++;if(count==5){j++;b[j]=0;}i=k;}}else{b[j]=a[i];}i++;j++;}printf(“After Bit Stuffing :”);for(i=0; i<j; i++)printf(“%d”,b[i]);return 0;} OUTPUT for …
Start reading Bit Stuffing Program in CImplementation of Queue operations using c programming. The Queue is implemented without any functions and directly written with switch case. Easy code for Queue operations using c. int main(){int queue[n],ch=1,front=0,rear=0,i,j=1,x=n;printf(“Queue using Array”);printf(“\n1.Insertion \n2.Deletion \n3.Display \n4.Exit”);while(ch){printf(“\nEnter the Choice:”);scanf(“%d”,&ch);switch(ch){case 1:if(rear==x)printf(“\n Queue is Full”);else{printf(“\n Enter no %d:”,j++);scanf(“%d”,&queue[rear++]);}break;case 2:if(front==rear){printf(“\n Queue is empty”);}else{printf(“\n Deleted Element is %d”,queue[front++]);x++;}break;case 3:printf(“\nQueue Elements are:\n …
Start reading Implementation of Queue using Array in Cinclude include int main (){int n, count;printf (“enter a number to print table:”);scanf (“%d”, &n); count = 1; start:if (count <= 10){printf (“%d*%d=%d\n”, n, count, n * count);count++;goto start;} return 0;} OUTPUT: enter a number to print table:881=8 82=1683=24 84=3285=40 86=4887=56 88=6489=72 810=80
Start reading C Program for Multiplication Table using Goto StatementThe Circumference of a Circle can be calculated using the formulae 2*PI*r In the below c program, the PI value taken as 3.14. All the values dealing with Decimals, so float is a Datatype. int is not a right datatype, it will remove all the decimal parts of output. include int main (){ float radius, circumference; …
Start reading C Program for Circumference of a Circleinclude include int main (){ int first = 0, second = 1, third, i, n; printf (“Enter the length of the fibonacci series \n”); scanf (“%d”, &n); printf (“The Fibonacci series is :\n”); printf (“%d%d”, first, second); for (i = 2; i <= n; i++) return 0; } OUTPUT: Enter the length of the fibonacci …
Start reading C Program for Fibonacci Series Using for LoopC Program for printing the Pascal Triangle up to given number of rows. What is Pascal Triangle? In simple, Pascal Triangle is a Triangle form which, each number is the sum of immediate top row near by numbers. The Value of edge is always 1. include int main(){int rows, cal = 1, space, i, j; …
Start reading C Program to Print Pascal TraingleThe following program will print numbers as pyramid. The sequence will be printed as specified in the below triangle format. If user enter number of rows as 5 then following output will be produced. 0 1 0 1 2 1 0 1 2 …
Start reading C Program to Print Pyramid of Numbers