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

C Program to Shutdown Linux OS

shutdown program in c

C Program to Shutdown Linux OS In this program : You need to be logged in as user for above program to execute otherwise you will get the message shutdown: “Need to be root”. ‘-P’ option specifies you want to power off your machine. You can specify minutes as: shutdown -P “number of minutes” Let see the below program #include<stdio.h> #include<stdlib.h> … Read more

C Program to shutdown Windows 7

shutdown program in c

C Program to shutdown Windows 7 This program turns off i.e shutdown your computer system. System function of stdlib.h is used to run an executable file shutdown.exe which is present in C:\WINDOWS\system32 folder in Windows 7 and XP #include<stdio.h> #include<stdlib.h> // to use system() method int main() { printf(“\n\n\t\tEduguru Shutdown program in c\n\n\n”); char ch; printf(“Do you want to … 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

C program to display odd numbers between 1 and 100

C program to display the odd digits present in integer

C program to display odd numbers between 1 and 100 #include<stdio.h> int main(){ int rem,i; printf(“\n The odd numbers between 1 and 100 are \n”); for(i=1; i<=100; ++i){ rem = i % 2; if(rem != 0) printf(“\n  %d”,i); } return 0; }