Write a C program to calculate the following series using for loop Sum= 1/3^2 +2/4^3 +3/5^4 + 4/6^5+ ... and print the result along with the series as the given format: when n=4; 1/3^2+2/4^3 +3/5^4+4/6^5 = 0.14768 similarly, print the result according to the nth term.
Write a C program to calculate the following series using for loop Sum= 1/3^2 +2/4^3 +3/5^4 + 4/6^5+ ... and print the result along with the series as the given format:
when n=4; 1/3^2+2/4^3 +3/5^4+4/6^5 = 0.14768
similarly, print the result according to the nth term.
The program is written in the C language , if you know the basics of C language than you can understand the program easily. If you the code for the same question in other language then please do comment for the help of others.
This program will support in any C compiler.
//Do follow and subscribe STAR tube
//Comment ...If you guys have any alternate method.
#include <stdio.h>
#include <math.h>
#include <conio.h>
int main()
{
clrscr;
int i,n;
int a=2,b=3;
float Sum=0;
scanf("%d",&n);
printf("when n=%d,",n);
for(i=1;i<=n;i++)
{
Sum = Sum + i/(pow(b,a));
b++;
a++;
}
for(i=1;i<=n;i++)
{
printf("%d%d%d",i,(i+2),(i+1));
if(i<n){
printf(" + ");
}
}
printf(" = %f",Sum);
return 0;
getch();
}
Write a C program in C that calls User defined function to calculate exponent of a number with following condition.
a. The function named ?getexp? takes two arguments: base number ?b? and the exponent ?n?. The function should calculate (b)n and return the result to main function.
b. Main function reads the base number and the exponent from user. Main function should call the user defined function ?getexp? which returns the result. Display the result in main.
c. Student should not use Built-in function for finding exponent.
The program is written in the C language , if you know the basics of C language than you can understand the program easily. If you the code for the same question in other language then please do comment for the help of others.
This program will support in any C compiler.
//Do follow and subscribe STAR tube
//Comment ...If you guys have any alternate method.
#include <stdio.h>
int getexp(b,n)
{
int i;
int a=b;
for(i=2;i<=n;i++)
{
a = a*b;
}
return a;
}
void main()
{
int ans=0;
int n,b;
printf("Enter base number:");
scanf("%d",&b);
printf("Enter exponent value:");
scanf("%d",&n);
ans = getexp(b,n);
printf("answer = %d",ans);
}
You are searching for a city in a country and you?re asked to select a country from a choice of three country namely:
India
Spain
UK
Having selected a country you are again provided with a list of city in that country namely:
1. India
a. Mumbai
b. Delhi
2. Spain
a. Madrid
b. Savile
3. UK
a. Bristol
b. bath
Write a C program to implement above using nested switch case statement.
The program is written in the C language , if you know the basics of C language than you can understand the program easily. If you the code for the same question in other language then please do comment for the help of others.
This program will support in any C compiler.
//Do follow and subscribe STAR tube
//Comment ...If you guys have any alternate method.
#include <stdio.h>
#include <conio.h>
int main()
{
clrscr;
int i;
printf("Select a country\nIndia press 1 \nSpain press 2 \nUK press 3\n");
scanf("%d",&i);
switch(i)
{
case 1:
printf("1.India\na.Mumbai\nb.Delhi");
break;
case 2:
printf("2.Spain\na.Mandrid\nb.Savile");
break;
case 3:
printf("3.UK\na.Bristol\nb.bath");
break;
}
return 0;
getch();
}
Write a C program to print the following symbol series (front and back slash - 5 times) as given below:
/ / \ / \ / \ / \ \
The program is written in the C language , if you know the basics of C language than you can understand the program easily. If you the code for the same question in other language then please do comment for the help of others.
//Do follow and subscribe STAR tube
//Comment ...If you guys have any alternate method.
#include <stdio.h>
#include <conio.h>
int main()
{
clrscr;
int i,j;
for(i=0;i<=5;i++)
{
if(i==0)
{
printf("/");
printf("\t");
}
else if(i==5)
{
printf("\\");
printf("\t");
}
else
{
printf("/");
printf("\\");
printf("\t");
}
}
return 0;
getch();
}
Comments
Post a Comment