write a C program to calculate the sum of its digits

C Programming Tutorial

Problem Statement: If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. Answer: /* Sum of digits of a 5 digit number*/ #include<stdio.h> #include<conio.h> main() { int num,a,n; int sum=0; /* this has been initialised to zero otherwise it will contain a garbage value */ clrscr(); … Read more

program in C to get the largest element of an array

C Programming Tutorial

program in C to get the largest element of an array Problem Statement: Write a program in C to get the largest element of an array using the function.   Test Cases: Input the number of elements to be stored in the array :10 Input 10 elements in the array : element – 0 : … Read more

Write basic C program to calculate gross salary

C Programming Tutorial

Write a C Program for the following :- Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary. Answer:  /* To Calculate the gross salary of Ramesh */ #include<stdio.h> #include<conio.h> main() { … Read more

Moving car program in C++

C Programming Tutorial

Moving Car Program in C++ This program is written in C++ using graphics to create and move a car. A car is made using two rectangles and two circles which act as tyres of car. A for loop is used to move the car forward by changing the rectangle and circle coordinates and erasing the … Read more

Graphics Program in C++ for Analog Clock

C Programming Tutorial

Analog Clock is mini project  in a C ++ language. It is graphics application using graphic library <graphics.h>. This program is Compiled using Turbo C++. Here is the source code of this program in C++ using Graphics.   /*Program for analog CLock*/ #include <stdio.h> #include <conio.h> #include <math.h> #include <string.h> #include <graphics.h> #include <time.h> #include <dos.h> void minSecPos(int xrad, int midx, … Read more

C program to find armstrong number

C Programming Tutorial

What is Armstrong number? Sum of a number’s digits raised to the power total number of digits is armstrong number. Armstrong numbers example: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634 etc Explanation: 3 = 3^1 = 3 153 = 1^3 + 5^3 + 3^3 = 153 Non-Armstrong … Read more

Simple Calculator program in C

C Programming Tutorial

This is a simple calculator program written in C Language. It Performs addition, subtraction, multiplication or division depending the input from user. This usage switch case statement. Let see the C Program # include <stdio.h> int main() { char operator; double firstNumber,secondNumber; printf(“Enter an operator (+, -, *,): “); scanf(“%c”, &operator); printf(“Enter two operands: “); … Read more

tic-tac-toe game in c

C Programming Tutorial

This is a tic-tac-toe game in C Language.  You can this as a mini project in C Language.     #include<stdio.h> #include<conio.h> #include<stdlib.h> #include <windows.h> int board[10] = {2,2,2,2,2,2,2,2,2,2}; int turn = 1,flag = 0; int player,comp; void menu(); void go(int n); void start_game(); void check_draw(); void draw_board(); void player_first(); void put_X_O(char ch,int pos); COORD … Read more

Analog Clock Program in C

C Programming Tutorial

Here is simple C program for analog clock.  This can be used as a reference for project reference. /*Note press ctrl+pause break to stop the clock while executing in TC*/ #include<stdio.h> #include<graphics.h> #include<stdlib.h> #include<math.h> #include<dos.h> #include<time.h> #define PI 3.147 void clockLayout(); void secHand(); void hrHand(); void minHand(); int maxx,maxy; void main() { int gdriver=DETECT,gmode,error; initgraph(&gdriver,&gmode,“c:\turboc3\bgi\”); … Read more