a program to read the data for the customer, calculate the interest and service charge, and print the customer’s name, average balance, interest, and service charge.

//calculate interest and service charge for bank customer #include <stdio.h> int main() { char customer[30], acctNum[30]; double avgBalance, interest, service; int numTrans; printf(“Name? “); gets(customer); printf(“Account number? “); gets(acctNum); printf(“Average balance? “); scanf(“%lf”, &avgBalance); printf(“Number of transactions? “); scanf(“%d”, &numTrans); interest = avgBalance * 0.06; service = numTrans * 0.50; printf(“\nName: %s\n”, customer); printf(“Average balance: … Read more

C Program to find GCD of N Numbers

C program for GCD

C Program to find GCD of N Numbers #include<stdio.h> int main() { printf(“\n\n\t\tC Program for Greatest Common Divisor(GCD)\n\n\n”); int x, y =- 1; printf(“Enter numbers. To exit enter 0\n”); while(1) // infinite loop to take input { scanf(“%d”, &x); if(x < 1) break; else if(y ==- 1) // only 1 number entered, its GCD is … Read more

C Program to create a Menu Driven software using Switch Case

switch case flow chart

C Program to create a Menu Driven software using Switch Case #include<stdio.h> int main() { printf(“\n\n\t\tMenu driven program in c\n\n\n”); int choice, num, i; unsigned long int fact; while(1) { printf(“1. Factorial \n”); printf(“2. Prime\n”); printf(“3. Odd\\Even\n”); printf(“4. Exit\n\n\n”); printf(“Enter your choice : “); scanf(“%d”,&choice); switch(choice) { case 1: printf(“Enter number:\n”); scanf(“%d”, &num); fact = … Read more

Basic Program of Pointer

understanding c pointers

Basic Program of Pointer #include <stdio.h> int main() { printf(“\n\n\t\tEduguru – Pointer program\n\n\n”); int var = 24; // actual variable declaration int *p; p = &var; // storing address of int variable var in pointer p printf(“\n\nAddress of var variable is: %x \n\n”, &var); // address stored in pointer variable printf(“\n\nAddress stored in pointer variable … Read more

The First Windows Program in C

The First Windows Program in C

The First Windows Program in C To keep things simple we would begin with a program that merely displays a “Hello” message in a message box. Here is the program… #include <windows.h> int _stdcall WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdline, int nCmdShow ) { MessageBox ( 0, “Hello!”, “Title”, 0 ) ; return … Read more

C program to print pascal triangle

C program to print pascal triangle #include <stdio.h> long factorial(int); int main() { int i, n, c; printf(“Enter the number of rows you wish to see in pascal triangle\n”); scanf(“%d”,&n); for (i = 0; i < n; i++) { for (c = 0; c <= (n – i – 2); c++) printf(” “); for (c = 0 ; c <= i; c++) printf(“%ld “,factorial(i)/(factorial(c)*factorial(i-c))); printf(“\n”); } return 0; } long factorial(int n) { int c; long result = 1; for (c = 1; c <= n; c++) result = result*c; return result; }

Compare two integers in C

Selection-sort-step to compare

Compare two integers in C Algorithm Let’s first see what should be the step-by-step procedure to compare two integers− START Step 1 → Take two integer variables, say A & B Step 2 → Assign values to variables Step 3 → Compare variables if A is greater than B Step 4 → If true print … Read more

C program for matrix addition

matrix program in c

C program for matrix addition #include <stdio.h> int main() { int a, b, c, d; int m1[10][10], m2[10][10], sum[10][10]; printf(“Please enter the number of rows of matrix\n”); scanf(“%d”, &a); printf(“Please enter number of columns of matrix\n”); scanf(“%d”, &b); printf(“Please enter the elements of first matrix one by one\n”); for ( c = 0 ; c … Read more

Program to Check a whether a Number is Odd or Even using Switch Case

C program to display the odd digits present in integer

Program to Check a whether a Number is Odd or Even using Switch Case #include<stdio.h> int main(){ int number,remainder; clrscr(); printf(” Enter an integer number: “); scanf(“%d”,&number); remainder = abs(number) % 2; switch(remainder){ case 0 : printf(“\n %d is an even number.”,number); break; case 1 : printf(“\n %d is an odd number.”,number); break; } getch(); … Read more