source file name: PrimeFor.C #include <stdio.h> int main() { int d, no; int flag=1; // clrscr(); printf("\n enter any no: "); scanf("%d",&no); for(d= 2; d < no; d++) { if((no%d) == 0) { flag = 0; break; } } if (flag == 1) print…
Read more13) Write a Program to Calculate Electricity billing amount as per given criteria.
Write a program in C to Input meter number, current reading, previous reading and consumer type (residential (r) or Commercial (c) ). Calculate billing amount as per criteria given below. Residential Commercial Units Rate Units Rate 0-100 …
Read more12) Write a program that finds and display Minimum float number from Three input Float numbers.
source file name: Min3floats.C #include <stdio.h> int main() { float a,b,c; //clrscr(); printf("\n enter 3 float numbers"); ; scanf("%f%f%f",&a,&b,&c); if(a<b && a<c) printf(" \n A is Minimum number"); else { if(b<c) printf(…
Read more11) Write a program to displays Floyd's triangle output using while and for control statements.
Program: Shown below is a Floyd’s triangle. 1 2 3 4 5 6 7 8 9 10 11 15 …. …… 79 91. Write a program to print this triangle. source file name: Floydtr.C void main() { int n,le,ln; clrscr(); printf("Floyd's Triangle output: \n"); n=1; ln=1; while(ln<=15) { for(le=1;le<…
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 more14) Write a program that calculates Tax on Income . if Income >250000 then tax 5% , Income > 500000 then tax 20% and Income>1000000 then tax 30%.
source file name: incometax.C #include <stdio.h> int main() { long income,tax,taxamount; //clrscr(); printf("\n enter your income"); scanf("%ld",&income); if(income<250000) { printf(" you have no Tax "); } else { if(income>250000 && income<=500000) { taxamoun…
Read more8) Write a Windows JDBC program that insert,delete and clear record using GUI form and display all records of Result Set in JTable.
source file name: SwingJdbc.java import java.sql.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; class SwingJdbc extends JFrame implements ActionListener { JTextField t1,t2,t3; public SwingJdbc() { GridLayout gl=new GridLayout(0,2,15,15); setLayout(gl); JLabel l1=new JLabel("Enter Roll : &qu…
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 more10) Write a program to find the value of one number raised to the power of another. calculate the value of a^b.
source file name: power.C #include<stdio.h> void main() { int a,b,n; int pv=1; //clrscr(); printf("\n enter two numbers : "); scanf("%d%d",&a,&b); for(n=1;n<=b;n++) { pv=pv*a; } printf("\n %d raised %d power is:%d",a,b,pv); getch(); } output:
Read more9)Write a program to generate all combinations of forming a three digit number using digits 1,2 and 3 no repeat digit.
source file name: comb3dig.C #include<stdio.h> void main() { int a,b,c; int n; clrscr(); printf(" Forming 3-digit numbers:\n "); for(a=1;a<=3;a++) { for(b=1;b<=3;b++) { for(c=1;c<=3;c++) { n=100*a+10*b+1*c; if(a==b || a==c || b==c ) continue; printf("\n %d",n); } } } getch(); } out…
Read more7) Write a Windows JDBC program that add record using GUI form and display all records of Result table in TextArea.
source file name: jdbcform.java import java.sql.*; import java.awt.*; import java.awt.event.*; class jdbcform extends Frame implements ActionListener { TextField t1,t2,t3,t4; public jdbcform() { GridLayout gl=new GridLayout(0,2,15,15); setLayout(gl); Label l1=new Label("Enter Rollno"); Label l2=new Label(&q…
Read more6) Write a JDBC program that display Records of tables in both direction using Result Set Types.
source file name: JdbcResultTypes.java import java.sql.*; class JdbcResultTypes { public static void main(String[] args) { System.out.println("jdbc program on Result set Types"); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:odbc:…
Read more5) Write a Window based JDBC program that execute DDL and DML commands(SQL statements) entered in Text Field .
source file name: jdbcgui.java import java.sql.*; import java.awt.*; import java.awt.event.*; class jdbcgui extends Frame implements ActionListener { TextField t1; public jdbcgui() { FlowLayout fl=new FlowLayout(); setLayout(fl); Label l1=new Label("Enter any SQL statement: "); t1=new TextField(30); Button …
Read more8)Write a program that determines and displays the Armstrong numbers between 100 to 999.
source file name: Armnos.C void main() { int n,d,sum=0; int temp; clrscr(); printf("\n List of Armstrong numbers: 1 to 999 "); for(n=100;n<=999;n++) { sum=0; temp=n; while(temp>0) { d=temp%10; sum=sum+(d*d*d); temp=temp/10; } if(sum==n) printf("\n %d ",n); } getch(); } output:
Read moresource file name: Primeno.C #include<stdio.h> int main() { int n,t; int d; // clrscr(); printf("\n prime numbers between 1 to 100\n "); for(t=1;t<=100;t++) { n=t; d=2; while(d<n) { if(n%d==0) { break; } else d++; } if(d==n) printf(" %d ",n); } //getch(); return 0; } output:
Read moresource file name: Tablesfor.C void main() { int tn; int n=1; clrscr(); printf("\n enter any table nos 1 to 20: \n"); for(tn=1;tn<=20;tn++) { for(n=1;n<=10;n++) { printf(" %d ",tn*n); } printf("\n"); } getch(); } output:
Read more5) Write a program to calculate Simple interest for three different sets of p, n and r.
source file name: Simintfor.C void main() { int per; float si; float p,n,r; clrscr(); for(per=1;per<=3;per++) { printf("\n enter Primuim amount ( P) , Length of years (N) and Rate (R) of Deposited:"); scanf("%f%f%f",&p,&n,&r); si=(p*n*r)/100; printf("\n Simple Interest of Per…
Read moresource file name: Salaryfor.C void main() { int e; float bs; float da,hra,gs; clrscr(); for(e=1;e<=3;e++) { printf("\n enter Basic Salary:"); scanf("%f",&bs); da=bs*0.4; hra=bs*0.2 ; gs=bs+da+hra; printf("\n Gross Sal…
Read moresource file name: Table1.C void main() { int tn; int n=1; clrscr(); printf("\n enter any table no:"); scanf("%d",&tn); for(n=1;n<=10;n++) { printf("\n %d ",tn*n); } getch(); } output:
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 JDBC program that execute DDL and DML commands using Command Line Argument as SQL statement.
source file name: JdbcFlexible.java import java.sql.*; class JdbcFlexible { Connection conn; Statement st; String s=""; public JdbcFlexible(String str) { s=str; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn = DriverManager.getConnection("jdbc:odbc:javadsn"); st = conn.cre…
Read more3) Write a JDBC program that display records of Student table.(MS-Access Database)
source file name: JdbcSelect.java import java.sql.*; class JdbcSelect { public static void main(String[] args) { System.out.println("jdbc program"); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:odbc:javadsn"); Statement st…
Read more2) Write a JDBC program that insert Three records in Result table of MS-Access Database.
source file name: JdbcInsert.java import java.sql.*; class JdbcInsert { public static void main(String as[]) { System.out.println("JDBC Program"); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:javadsn"); Statement st=con.create…
Read more