Thursday 22 August 2013

C Programming beginners, Read Value from user

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
float x,y;
clrscr();

printf("Enter Value for A:");
scanf("%d",&a);// "&" points to address of variable where value will be stored
printf("Enter Value for B:");
scanf("%d",&b);
printf("Enter Value for C:");
scanf("%d",&c);
printf("You have entered...\nA:%d\nB:%d\nC:%d",a,b,c);

printf("\n\nEnter float value( value that contains decimal place, six digit after decimal point) ");
printf("\nEnter Value for X:");
scanf("%f",&x);
printf("Enter Value for Y:");
scanf("%f",&y);
printf("\nYou have entered...\nX:%d\nY:%d",x,y);
printf("\nYou have entered...\nX:%f\nY:%f",x,y);
printf("\none decimal place\nX:%.1f\nY:%.1f",x,y);
printf("\ntwo decimal places\nX:%.2f\nY:%.2f",x,y);


getch();
}

O/P:

No comments:

Post a Comment

Contact Form

Name

Email *

Message *