0 votes
102 views
in Discuss by (98.9k points)
reshown by
//11

#include<stdio.h>
#include<conio.h>
void main()
{
	int no1,no2,r,m,n;
	clrscr();
	printf("Enter two integer numbers : \n");
	scanf("%d%d",&no1,&no2);
	m=no1;
        n=no2;
	if(no1<no2)
	{
	no1=no1+no2;
	no2=no1-no2;
	no1=no1-no2;
	}
	do
	{
	r=no1%no2;
	no1=no2;
	no2=r;
	}while(r!=0);

	printf("GCD of two numbers: %d\n",no1);
	printf("LCM of two numbers: %d\n",(m*n)/no1);

	getch();
}



//12
//break
#include<stdio.h>
#include<conio.h>
void main()
{   int i, number, sum = 0;
for (i=1; i <= 10; ++i)
             {
        	printf("Enter a number:  ");
        	scanf("%d",  &number);
        	if(number < 0) { break; }
       	 sum += number;
              }
   printf("Sum = %d", sum);
    getch();
}

//continue
#include<stdio.h>
#include<conio.h>
void main()
{   int i, number, sum = 0;
   	for (i=1; i <= 10; ++i)
             {
        	printf("Enter a number:  ");
        	scanf("%d",  &number);
        	if(number < 0) { continue; }
       	 sum += number;
              }
   printf("Sum = %d", sum);
    getch();
}


//13

#include<stdio.h>
void fibo(int);
void main() 
{
   int n;    
   printf("\n Enter a number to generate Fibonacci series for first n terms\n");
   scanf("%d", &n);
   fibo(n);
}
void fibo(int n)
{
   int i, a=, b=1,c=0;
   printf("Fibonacci series for terms:-\n");
   for(i=0; i<n; i++)
   {
       printf("%d\n",c);
       a=b;
       b=c;
       c=a+b;
   }
}

//14

#include<stdio.h>
#include<conio.h>
void main()
{
	int no,factorial;
	int fact (int no);
	clrscr();

printf("Enter a number:");
	scanf("%d",&no);
	factorial=fact(no);
	printf("Factorial=%d",factorial);
	getch();
}
int fact (int no) { if(no==1) return 1; else return (no * fact (no-1)); }

//15

#include<stdio.h>
#include<conio.h>
void main( )
{
	int n,i,a[100],large;
clrscr();
     	printf("Enter the number of elements:");
	scanf("%d",&n);
	for(i=0;i<=n-1;i++) { 	printf("Enter a value:");    scanf("%d",&a[i]); }
	large=a[0];
	for(i=1;i<=n-1;i++) { 	if(large<a[i])  large=a[i]; }
	printf("The largest number is %d",large);
	getch();
}

 

by (98.9k points)
edited
Program 13
Fibo

a=0,

1 Answer

0 votes
by (98.9k points)
edited

Related questions

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

563 users

...