Showing posts with label Asked in Tech Mahindra. Show all posts
Showing posts with label Asked in Tech Mahindra. Show all posts

Saturday, 27 December 2014

What is the Output of the following Question - Daily Quetions






Program:

#include<stdio.h>
#include<conio.h>
void main( ) 
{
          int i,j;
          j = 10;
          i = j++ - j++;
          printf("%d %d", i,j);

}

Solution:

       j=10
       i= 10 - 10
j value  is incremented by two times.
So,Output is 0, 12



Wednesday, 20 August 2014

C Program for the following Statement



Statement:

                              Harish'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 gross salary.


Program:

#include<stdio.h>
#include<conio.h>
void main( )
{
int s,da,hra,gs;
clrscr( ); // Clear the screen contents
printf("\nEnter the Basic Salary:");
scanf("%d",&s);
da=(s*40)/100;
hra=(s*20)/100;
gs=s+da+hra;
printf("\nDearness Allowance %d",da);
printf("\nHouse rent allowance %d",hra);
printf("\nGross Salary is %d",gs);
}