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

Hierarchy of Operators Revisited in C

C Programming Tutorial

Since we have now added the logical operators to the list of operators we know, it is time to review these operators and their priorities. The higher the position of an operator is in the table, higher is its priority. The following figure summarizes the working of all the three logical operators.

C Program to calculate the salary

C Programming Tutorial

Problem Statement: Write a program to calculate the salary as per the following table: Solution: /* C program to calculate salary */ main( ) { char g ; int yos, qual, sal ; printf ( “Enter Gender, Years of Service and Qualifications ( 0 = G, 1 = PG ):” ) ; scanf ( “%c%d%d”, &g, … Read more

write a C program to obtain the sum of the first and last digit of this number

C Programming Tutorial

Problem Statement: If a four-digit number is input through the keyboard, write a program to obtain the sum of the first and last digit of this number. Solution: /* Sum of 1st and last digit of a four digit number */ #include<stdio.h> #include<conio.h> main() { int n,a,sum=0; clrscr(); printf(“\Enter a four digit number”); scanf(“%d”,&n); a=n/1000; … Read more

Write a C program to interchange the contents of C and D

C Programming Tutorial

Problem Statement :  Two numbers are input through the keyboard into two locations C and D. Write a program to interchange the contents of C and D. Answer: /* Interchanging of contents of two variables c & d */ #include<stdio.h> #include<conio.h> main() { int c,d,e; clrscr(); printf(“\n Enter the number at location C:”); scanf(“%d”, &c); … Read more

write a C program for Conversion of Temperature from Fahrenheit to Centigrade

C Programming Tutorial

Problem Statement: Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a c program to convert this temperature into Centigrade degrees. Answer: /* Conversion of Temperature from Fahrenheit to Centigrade */ #include <stdio.h> #include <conio.h> main() { float fr, cent; clrscr(); print(“\n Enter the temperature in Fahrenheit:”); scanf(“%f”, &fr); cent=5.0/9.0*(fr-32); printf(“\n … Read more

Write a c program for Calculation of aggregate and percentage marks

C Programming Tutorial

Problem Statement: If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100. Answer: /* Calculation of aggregate and percentage marks … Read more