Wednesday, March 18, 2015

வாங்க பழகலாம் c மொழியை-6 ம் பகுதி.


scanf() function
scanf function உள்ளீடு(input) வாங்க பயன்படுகின்றது. எல்லா வகையான டேடா டைபிற்கும் இதில் உள்ளீடு வாங்கலாம்.
syntax::
scanf (“format specifier”,&var );

இதில் format specifier என்பது %d, %f போன்றவையாகும்.var என்பது வேரியபிலின் பெயராகும். & என்பது வேரியபிலின் நினைவக முகவரியை குறிக்கின்றது.

உதாரணமாக

1.   Int a;
     scanf(“%d”, &a);
2.   float x;
     scanf(“%f”,&x);
3.   int a;
      float b
      scanf(“%d %f”,&a,&b;

உதாரண நிரல்கள்

//program 6.1
//program to add two numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,sum;
clrscr();
printf(“enter a”);
scanf(“%d”,&a);
printf(“enter b”);
scanf(“%d”,&b);
sum=a+b;
printf(“sum of %d and %d is %d”,a,b,sum);
getch();
}
போன பாடத்தில் program 5.1 –ல் a,b வேரியபிளுக்கு மதிப்பு நிரலிலேயே இருத்தப் பட்டிருந்தது. இந்த நிரலில் (5.2) a,b வேரியபிளுக்கு நிரலின் இயக்க நேரத்தில் உள்ளீடு செய்யப் படும்.
output:
enter a :50
enter b:75
sum of 50 and 75 is 125.
இதே நிரலை மீண்டும் ஒரு முறை இயக்கி வேறு உள்ளீடுகள் கொடுத்து அதற்குரிய வெளீயீடுகளை காணலாம்.
//program 6.2
//program to find area of rectangle
#include<stdio.h>
#include<conio.h>
void main()
{
int l,b,area;
clrscr();
printf(“enter length and breadth of rectangle”);
scanf(“%d %d”,&l,&b);
area=l*b;
printf(“area of rectangle is %d”,area);
getch();
}
output:
enter length and breadth of rectangle 10 20
area of rectangle is 200.

நான் மதுரையில் சொந்தமாக ப்ரோக்ராமிங் மொழிகளான c, c++, java, c#, vb.net, asp.net, php, servlet, jsp, ejb,html,css, javascript மற்றும் வேலை வாய்ப்பிற்கான ms-office, tally, photoshop, coreldraw முதலியவற்றை கற்பித்து வருகின்றேன்.

தொடர்புக்கு:
contact number:
96293 29142

Email id:                  
muthu.vaelai@gmail.com

எனது பிற வலைத் தளங்கள்.




ads Udanz

No comments:

Post a Comment