Write a program that determine the value of following series up-to n. 1+x+x 2 +x 3 +x 4 +………………………+x n #include <stdio.h> int main() { int x,n,ln,tn,psum=0,sum=0; //clrscr(); printf("\n enter x and power n"); scanf("%d%d",&x,&ln); sum=1; n=1; do { psum=1; for(tn=1;tn<=n;…
Read more13) Write a program to calculate and print the first m Fibonacci numbers using Do-While loop.
The numbers in the sequence 1 1 2 3 5 8 13 21 …………………….. are called Fibonacci numbers. After the first two numbers in the series, each number is the sum of the two preceding numbers. source file name: Fibnums.C #include<stdio.h&…
Read more12) Write a program that displays Upper case and Lower case letters using While Loop.
source file name: UpperLower.C void main() { char ch; clrscr(); printf("\n Upper case letters\n "); ch=65; while(ch<=90) { printf(" %c ",ch); ch++; } printf("\n Lower case letters\n "); ch=97; while(ch<=122) { printf(" %c ",ch); ch++; } getch(); } output:
Read more11) Write a program that finds persistence value of given number using Do-While control statement.
program: Write a program that determines persistence value of given number. Input 2 digit positive integer number through keyboard. e.g. persistence value of 49 is 3. 49,4*9=36, 3*6=18 , 1*8=1. e.g. persistence value of 77 is 4. 77,7*7=49, 4*9=36, 3*6=18 , 1*8=1. source file name: persitval.C void main() { int n,d1,…
Read more10) Write a program to find the LCM and GCD of any two non-zero integers , input 2 numbers in ascending order.
source file name: gcdlcm.C #include<stdio.h> void main() { int a,b,t; int gcd,lcm; clrscr(); printf("\n enter two numbers(first no less than second no) : "); scanf("%d%d",&a,&b); t=a; while(a>1) { if(a%t==0 && b%t==0) { gcd=t; break; } else t--; } lcm=a*b/gcd; printf(&quo…
Read more9) Write a program to check whether the given number is a prime number or not.(use of While loop)
source file name: primeno.C void main() { int n,m=0; int d,op=0; clrscr(); printf("\n enter any no:"); scanf("%d",&n); m=n/2; d=2; while(d<=m) { if(n%d==0) { printf("\n given no is not Prime no"); op=1; break; } else d++; } if(op==0) printf("\n given no is Prime no "); g…
Read moreWrite a program to calculate overtime pay of 10 employees. Overtime is paid at the rate of Rs. 120.00 per hour for every hour worked above 40 hours. Assume that employees do not work for fractional part of an hour. source file name: empot.C void main() { int twh,oth; int emp; int otamt; clrscr(); emp=1; while(emp&l…
Read more7) Write a program to input an integer of 10 digits, and to find the sum of the digits in the given integer.
source file name: While6.C void main() { long n; int d,sum=0; clrscr(); printf(" enter any no: \n"); scanf("%ld",&n); while(n>0) { d=n%10; sum=sum+d; n=n/10; } printf("\n sum of digit= %d ",sum); getch(); } output: 1. enter any no: 12345 sum of digit=15 2. enter any no: 123456…
Read moresource file name: While4.C void main() { int n; int sq,c; clrscr(); printf(" square and cube numbers between 1 to 25 "); n=1; while(n<=25) { sq=n*n; c=n*n*n; printf("\n %d %d %d ",n,sq,c); n++; } getch(); } output:
Read moresource file name: While3.C #include<stdio.h> int main() { int n; int sum=0; //clrscr(); n=1; // start while(n<=100) // end { sum=sum+n; n++; // interval } printf("\n sum: %d ",sum); // body //getch(); return 0; } output: sum: 5050
Read moresource file name: While1.C void main() { int n; clrscr(); printf(" To display numbers 1 to to 10: "); n=1; // start while(n<=10) // end { printf("\n %d ",n); // body n++; // interval } getch(); } output:
Read more4) Write a program to finds and display divisible by 7 numbers 100 to 200 and sum of it.
souce code: divisible7.c #include<stdio.h> void main() { int n,sum=0; clrscr(); n=100; printf(" numbers divisble by 7 from 100 to 200 : \n "); while(n<200) { if(n%7==0) { printf(" %d ",n); sum=sum+n; } n++; } printf(" \n sum =%d ",sum); getch(); } output:
Read more#include<stdio.h> #include<conio.h> int main() { int n,d; //clrscr(); printf("\n\tEnter any number"); scanf("%d",&n); d=2; while(d<n) { if(n%d==0) { printf("\tGiven no is not prime number"); break; } else d++; } if(n==d) print…
Read more#include<stdio.h> #include<conio.h> int main() { int n,tn; //clrscr(); printf("\n\tEnter table no"); scanf("%d",&tn); n=1; while(n<=10) { printf("%d ",tn*n); n=n+1; } //getch(); return 0; } Output: Enter table no: 7 7 14 21 28 35 42 4…
Read more