C Program if - while - for Example How to write a C Program if - while - for Example in C Programming Language ? Solution For C Program :
C Program if - else if - else Example How to write a C Program if - else if - else Example in C Programming language ? Solution For C Program :
C Program to Calculation of Bonus using 'if' statement How to write a C Program to Calculation of Bonus using 'if' statement in C Programming Language ? Solution: This program is nothing but the demonstration of 'if' statement.The current year and the year in which the employee joined the organizationare entered through the keyboard. If the number of years for which the employee has served the organization is greater than 3 then a bonus of Rs. 2500/- is given to the employee. If the years of service are not greater than 3, then the program should not do anything. If his basic salary is less than Rs. 1500, then HRA=10% of basic salary and DA=90% of basic salary. If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. If the employee's salary is input through the keyboard write a program to find his gross salary. #include<stdio.h> main () { int bonus, cy, yoj, yr_of_ser; printf ("Enter current year and year of joining: "); scanf ("%d %d", &cy, &yoj); yr_of_ser = cy - yoj; if (yr_of_ser>3) { bonus = 2500; printf ("Bonus = Rs. %d", bonus); } }
C Program To Find Prime Number And If Number Is Not Prime Then Find Factors Write a C program to find prime number and if number is not prime then find factors of the number in C Programming Language ? Solution: #include <stdio.h> #include <conio.h> void main() //C Program to Check whether the Given Number is a Prime //C program to display all the factors of a number entered by user. { int flag=0,i,n,r,a[100],b=0,s; clrscr(); printf("\n Enter Number: "); scanf("%d",&n); for(i=2;i<=n/2;i++) { r=n%i; if(r==0) { flag=s; a[b]=i; b++; } } if(flag==s) { printf(" So The Number %d is not prime",n); printf("\n The factors are: "); for(i=0;i<b;i++) { printf("%d ",a[i]); } } else { printf("\n So The Number %d is prime",n); } getch(); }