0% found this document useful (0 votes)
49 views7 pages

Advance C Programming: Name: Komal R. Kashyap Branch: Cse 2 Year College: Sscet (Bhadrawati)

The document contains the name and details of a student and solutions to 6 C programming questions. The solutions demonstrate how to write programs to: 1) Display a pattern of asterisks 2) Print the first n Fibonacci numbers 3) Calculate the sum of a series involving powers of x 4) Find the roots of a quadratic equation 5) Check if a number is prime and generate prime numbers up to n 6) Find the largest of five integer numbers

Uploaded by

Komal Kashyap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views7 pages

Advance C Programming: Name: Komal R. Kashyap Branch: Cse 2 Year College: Sscet (Bhadrawati)

The document contains the name and details of a student and solutions to 6 C programming questions. The solutions demonstrate how to write programs to: 1) Display a pattern of asterisks 2) Print the first n Fibonacci numbers 3) Calculate the sum of a series involving powers of x 4) Find the roots of a quadratic equation 5) Check if a number is prime and generate prime numbers up to n 6) Find the largest of five integer numbers

Uploaded by

Komal Kashyap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

..

ADVANCE C PROGRAMMING
NAME: KOMAL R. KASHYAP
BRANCH: CSE 2 YEAR
COLLEGE: SSCET(BHADRAWATI)
1.Write a program to display the following pattern or screen.

*********
**** ****
*** ***
** **
* *

Answer:
#include<stdio.h>

#include<conio.h>

void main()

int i,j;

for(i=1;i<=5;i++)

for(j=1;j<=9;j++)

if(j<=6-i || j>=4+i)

printf(“*”);

else

{
OUTPUT:
printf(“\t”);
*********
} **** ****
*** ***
} ** **
* *
printf(“\n”);

getch();

}
2.write a program to print first n fibonacies series.

Answer:

#include<stdio.h>

#include<conio.h>

Void main()

int n,f=0,s=1,t,i=1;

clrscr();

printf(“enter the value of n”);

scanf(“%d”,&n);

printf(“%d\t%d\t”,f,s);

while(i<=n-2)

t=f+s;

f=s;

s=t;

printf(“%d\t”,t);

i++;

getch();

OUTPUT:

Enter the value of n 5

3
3.write a C program to find the sum of the series.
𝑥 𝑥2 𝑥3 𝑥𝑛
s = 1 + 1! + + +
2! 3! 𝑛!

Answer:

#include<stdio.h>

#include<conio.h>

void main()

int n,x,i,j,row;

float sum=0.0;

clrscr();

printf(“enter the value of x & n”);

scanf(“%d%d”,&x&n);

for(i=1;i<=n;i++)

fact=1;

for(j=1;j<=I;j++)

fact=fact*j;

sum=sum+pow(x,i)/fact;

printf(“sum=%f”,sum);

getch();

}
OUTPUT:

Enter the value of x & n

5 15

Sum=0.2837
4. write a C program to find root of a quadratic equation.

Answer:

#include<stdio.h>

#include<conio.h>

void main()

int a,b,c,d;

float x1,x2;

clrscr();

printf(“enter value of a, b & c”);

scanf(“%d%d%d”,&a,&b,&c);

d=(b*b)-(4*a*c);

if(d>0)

x1=(-b+sqrt(d)/(2*d));

x2=(-b-sqrt(d)/(2*d));

else

printf(“number are imaginary”);

getch();

OUTPUT:

enter the value of a, b & c

2.3 4 5.6

number are imaginary

-0.87+1.30i and -0.87-1.30i


5.program to check and generate prime number up to n.

Answer:

#include<stdio.h>

#include<conio.h>

void main()

int num,i=2;

clrscr();

printf(“enter an integer number”);

scanf(“%d”,&num);

while(i<=num-1)

if(num%i==0)

printf(“number is not prime”);

break;
OUTPUT:
}
enter an integer number
i++;
97
}
number is prime
if(i==num)

printf(“number is prime”);

getch();

}
6.write a program to find the largest element for five integer number.

Answer:

#include<stdio.h>

#include<conio.h>

void main()

int a,b,c,d,e,large=a;

clrscr();

printf(“enter the five integer number”);

scanf(“%d%d%d%d%d”,&a,&b,&c,&d,&e);

large=a;

if(b>large)

large=b;

if(c>large)

large=c;

if(d>large)
OUTPUT:
large=d;
enter the five integer number
if(e>large)
10 20 30 40 50
large=e;

printf(“%d”,large);
50
}

You might also like